diff options
Diffstat (limited to 'static/frontend-testing.ts')
-rw-r--r-- | static/frontend-testing.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/static/frontend-testing.ts b/static/frontend-testing.ts new file mode 100644 index 000000000..f11061957 --- /dev/null +++ b/static/frontend-testing.ts @@ -0,0 +1,30 @@ +import { ICEFrontendTesting, ICETestable } from './frontend-testing.interfaces'; + +class CEFrontendTesting implements ICEFrontendTesting { + private testSuites: Array<ICETestable>; + + constructor() { + this.testSuites = []; + } + + public add(test: ICETestable) { + this.testSuites.push(test); + } + + private findTest(name: string) { + for (const suite of this.testSuites) { + if (suite.description === name) { + return suite; + } + } + + throw new Error(`Can't find test ${name}`); + } + + public async run(testToRun: string) { + const testSuite = this.findTest(testToRun); + await testSuite.run(); + } +} + +window.frontendTesting = new CEFrontendTesting(); |