-
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
221 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { IHowto, IHowtoStep } from '../../src/models/howto.models' | ||
import chaiSubset from 'chai-subset' | ||
|
||
declare global { | ||
namespace Chai { | ||
// tslint:disable-next-line:interface-name | ||
interface Assertion { | ||
containSubset(expect: any): any; | ||
eqHowtoStep(expect: any, index: number) | ||
} | ||
} | ||
} | ||
|
||
const eqHowto =(chaiObj, utils) => { | ||
function compare(this: any, expected: any) { | ||
const subject: IHowto = this._obj | ||
const { _createdBy, _deleted, caption, description, difficulty_level, slug, time, title , tags} = expected | ||
expect(subject, 'Basic info').to.containSubset({ _createdBy, _deleted, caption, description, difficulty_level, slug, time, title , tags}) | ||
expect(subject.cover_image, 'Cover images').to.containSubset(expected.cover_image) | ||
|
||
expected.steps.forEach((step, index) => { | ||
expect(subject.steps[index], `Have step ${index}`).to.eqHowtoStep(step, index) | ||
}) | ||
} | ||
chaiObj.Assertion.addMethod('eqHowto', compare) | ||
} | ||
const eqHowtoStep = (chaiObj, utils) => { | ||
function compare(this: any, expected: any, index: number) { | ||
const subject: IHowtoStep = this._obj | ||
const {_animationKey, caption, text, title} = expected | ||
expect(subject, `Step ${index} with info`).to.containSubset({_animationKey, caption, text, title}) | ||
expect(subject.images, `Step ${index} with images`).to.containSubset(expected.images) | ||
} | ||
|
||
chaiObj.Assertion.addMethod('eqHowtoStep', compare) | ||
} | ||
chai.use(eqHowto); | ||
chai.use(eqHowtoStep); | ||
chai.use(chaiSubset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters