1 |
|
2 |
|
3 | const expect = require('chai').expect
|
4 | const tymly = require('./../lib')
|
5 | const path = require('path')
|
6 |
|
7 | describe('Mods tests', function () {
|
8 | this.timeout(process.env.TIMEOUT || 5000)
|
9 |
|
10 | const expectedPath = './expected/simpsons-blueprint'
|
11 |
|
12 | let tymlyService, models, cardTemplates, functions, images
|
13 |
|
14 | before('boot Tymly', async () => {
|
15 | const tymlyServices = await tymly.boot({
|
16 | blueprintPaths: [
|
17 | path.resolve(__dirname, './fixtures/blueprints/simpsons-blueprint'),
|
18 | path.resolve(__dirname, './fixtures/blueprints/space-blueprint'),
|
19 | path.resolve(__dirname, './fixtures/blueprints/people-blueprint')
|
20 | ],
|
21 | modPaths: [
|
22 | path.resolve(__dirname, './fixtures/mods/simpsons-mod')
|
23 | ]
|
24 | })
|
25 |
|
26 | tymlyService = tymlyServices.tymly
|
27 |
|
28 | const { blueprintComponents } = tymlyService
|
29 |
|
30 | models = blueprintComponents.models
|
31 | cardTemplates = blueprintComponents.cardTemplates
|
32 | functions = blueprintComponents.functions
|
33 | images = blueprintComponents.images
|
34 | })
|
35 |
|
36 | it('simple card template operations', () => {
|
37 | const actual = cardTemplates.tymlyTest_orderAtMoes_1_0
|
38 | const expected = require(`${expectedPath}/card-templates/order-at-moes.json`)
|
39 | expect(actual).to.eql(expected)
|
40 | })
|
41 |
|
42 | it('simple model operations', () => {
|
43 | const actual = models.tymlyTest_moesDrinksOrders
|
44 | const expected = require(`${expectedPath}/models/moes-drinks-orders.json`)
|
45 | expect(actual).to.eql(expected)
|
46 | })
|
47 |
|
48 | it('remove operation', () => {
|
49 | const actual = cardTemplates.tymlyTest_toRemove_1_0
|
50 | const expected = require(`${expectedPath}/card-templates/to-remove.json`)
|
51 | expect(actual).to.eql(expected)
|
52 | })
|
53 |
|
54 | it('replace function', () => {
|
55 | const actual = functions.tymlyTest_helloWorldFunction
|
56 | const expected = require(`${expectedPath}/functions/hello-world-function.js`)
|
57 | expect(actual()()).to.eql(expected()())
|
58 | })
|
59 |
|
60 | it('replace image', () => {
|
61 | const actual = images['tymlyTest_simpsons.png'].filePath
|
62 | const expected = path.resolve(__dirname, './fixtures/mods/simpsons-mod/images/simpsons.png')
|
63 | expect(actual).to.eql(expected)
|
64 | })
|
65 |
|
66 | after('shutdown Tymly', async () => {
|
67 | await tymlyService.shutdown()
|
68 | })
|
69 | })
|