Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('Tests cm', function () {
- let christmas;
- beforeEach(() => {
- christmas = new ChristmasMovies();
- });
- describe('constructor ', function () {
- it('assert with valid params', () => {
- assert.deepEqual(christmas.movieCollection, []);
- assert.deepEqual(christmas.watched, {});
- assert.deepEqual(christmas.actors, []);
- assert.deepEqual(christmas.actors.length, 0);
- assert.deepEqual(christmas.movieCollection.length, 0);
- });
- });
- describe('method 1 ', function () {
- it('assert with valid params', () => {
- assert.equal(
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']),
- 'You just got Home Alone 2 to your collection in which Macaulay Culkin are taking part!'
- );
- // assert.isTrue(christmas.movieCollection.length === 1);
- assert.equal(
- christmas.buyMovie('Last Christmas', [
- 'Emilia Clarke',
- 'Henry Golding',
- 'Emilia Clarke',
- ]),
- 'You just got Last Christmas to your collection in which Emilia Clarke, Henry Golding are taking part!'
- );
- // assert.isTrue(christmas.movieCollection.length === 2);
- // assert.isTrue(christmas.actors.length === 0);
- assert.equal(
- christmas.buyMovie('The Grinch', [
- 'Benedict Cumberbatch',
- 'Pharrell Williams',
- ]),
- 'You just got The Grinch to your collection in which Benedict Cumberbatch, Pharrell Williams are taking part!'
- );
- assert.Throw(
- () =>
- christmas.buyMovie('The Grinch', [
- 'Benedict Cumberbatch',
- 'Pharrell Williams',
- ]),
- 'You already own The Grinch in your collection!'
- );
- });
- it('assert with invalid params', () => {
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- christmas.buyMovie('Last Christmas', [
- 'Emilia Clarke',
- 'Henry Golding',
- ]);
- assert.Throw(
- () => christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']),
- 'You already own Home Alone 2 in your collection!'
- );
- assert.Throw(
- () =>
- christmas.buyMovie('Last Christmas', [
- 'Emilia Clarke',
- 'Henry Golding',
- ]),
- 'You already own Last Christmas in your collection!'
- );
- });
- });
- describe('method 2 ', function () {
- it('assert with valid params', () => {
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- christmas.watchMovie('Home Alone 2');
- assert.equal(
- christmas.discardMovie('Home Alone 2'),
- 'You just threw away Home Alone 2!'
- );
- assert.equal(Object.keys(christmas.watched).length, 0);
- });
- it('assert with invalid params', () => {
- assert.Throw(
- () => christmas.discardMovie('Home Alone 2'),
- 'Home Alone 2 is not at your collection!'
- );
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- assert.Throw(
- () => christmas.discardMovie('Home Alone 2'),
- 'Home Alone 2 is not watched!'
- );
- });
- });
- describe('method 3 ', function () {
- it('assert with valid params', () => {
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- christmas.watchMovie('Home Alone 2');
- assert.equal(Object.keys(christmas.watched).length, 1);
- assert.equal(christmas.watched['Home Alone 2'], 1);
- christmas.watchMovie('Home Alone 2');
- assert.equal(Object.keys(christmas.watched).length, 1);
- assert.equal(christmas.watched['Home Alone 2'], 2);
- christmas.watchMovie('Home Alone 2');
- assert.equal(christmas.watched['Home Alone 2'], 3);
- });
- it('assert with invalid params', () => {
- assert.throw(
- () => christmas.watchMovie('Home Alone 2'),
- 'No such movie in your collection!'
- );
- });
- });
- describe('method 4 ', function () {
- it('assert with valid params', () => {
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- christmas.buyMovie('Last Christmas', [
- 'Emilia Clarke',
- 'Henry Golding',
- ]);
- christmas.buyMovie('The Grinch', [
- 'Benedict Cumberbatch',
- 'Pharrell Williams',
- ]);
- christmas.watchMovie('Home Alone 2');
- assert.equal(
- christmas.favouriteMovie(),
- 'Your favourite movie is Home Alone 2 and you have watched it 1 times!'
- );
- christmas.watchMovie('The Grinch');
- christmas.watchMovie('Last Christmas');
- christmas.watchMovie('Home Alone 2');
- christmas.watchMovie('Home Alone 2');
- christmas.watchMovie('Last Christmas');
- assert.equal(
- christmas.favouriteMovie(),
- 'Your favourite movie is Home Alone 2 and you have watched it 3 times!'
- );
- christmas.discardMovie('Home Alone 2');
- assert.equal(
- christmas.favouriteMovie(),
- 'Your favourite movie is Last Christmas and you have watched it 2 times!'
- );
- });
- it('assert with invalid params', () => {
- christmas.buyMovie('The Grinch', [
- 'Benedict Cumberbatch',
- 'Pharrell Williams',
- ]);
- assert.Throw(
- () => christmas.favouriteMovie(),
- 'You have not watched a movie yet this year!'
- );
- });
- });
- describe('method 5 ', function () {
- it('assert with valid params', () => {
- christmas.buyMovie('Home Alone 2', ['Macaulay Culkin']);
- christmas.buyMovie('Home Alone', [
- 'Macaulay Culkin',
- 'Emilia Clarke',
- ]);
- christmas.buyMovie('Home Alone 3', [
- 'Macaulay Culkin',
- 'Emilia Clarke',
- ]);
- christmas.buyMovie('Last Christmas', [
- 'Emilia Clarke',
- 'Henry Golding',
- ]);
- christmas.buyMovie('The Grinch', [
- 'Benedict Cumberbatch',
- 'Pharrell Williams',
- ]);
- assert.equal(
- christmas.mostStarredActor(),
- 'The most starred actor is Macaulay Culkin and starred in 3 movies!'
- );
- christmas.watchMovie('Home Alone 2');
- christmas.discardMovie('Home Alone 2');
- assert.equal(
- christmas.mostStarredActor(),
- 'The most starred actor is Emilia Clarke and starred in 3 movies!'
- );
- });
- it('assert with invalid params', () => {
- assert.Throw(
- () => christmas.mostStarredActor(),
- 'You have not watched a movie yet this year!'
- );
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement