const { assert } = require('chai') const fs = require('fs') const PagesQuery = require('./../src/queries/pages.js') const configStore = require('./../src/config.js') describe('Page /index.md', function () { configStore.set('source', './ressources') configStore.set('destination', './dist') const query = new PagesQuery('./ressources'); const results = query.find() const page = results[2] it('fields is Object', function() { assert.isObject(page) }) it('fields has Blocks', function() { assert.equal(page.blocks.block.length, 2) }) it('path', function() { assert.equal(page.path, '/index.html') }) it('permalink', function() { assert.equal(page.permalink, '') }) it('parsed content contains image', () => { assert.match(page.content, /_images\/dog.jpg/) }) }) describe('Page /blog/index.md', function () { configStore.set('source', './ressources') configStore.set('destination', './dist') const query = new PagesQuery('./ressources'); const results = query.find() const page = results[1] it('fields is object', function() { assert.isObject(page) }) it('fields has Blocks', function() { assert.equal(page.blocks.block.length, 2) }) it('path', function() { assert.equal(page.path, '/blog/index.html') }) it('permalink', function() { assert.equal(page.permalink, '/blog') }) it('fields has media src', function() { assert.deepEqual(page.media.src, { "300": "/assets/a6c45d17/11bf0a4e/a2b1d75d/dc85ca56/71c63294/dog300.webp", "500x100": "/assets/a6c45d17/11bf0a4e/a2b1d75d/dc85ca56/71c63294/dog500x100.webp", "full": "/assets/a6c45d17/11bf0a4e/a2b1d75d/dc85ca56/71c63294/dog.webp" }) }) }) describe('Page /blog/article.md', function () { configStore.set('source', './ressources') configStore.set('destination', './dist') const query = new PagesQuery('./ressources'); const results = query.find() const page = results[0] it('fields is object', function() { assert.isObject(page) }) it('path', function() { assert.equal(page.path, '/blog/article.html') }) it('permalink', function() { assert.equal(page.permalink, '/blog/article') }) it('fields has media src', function() { assert.equal(page.media.src, '/assets/a6c45d17/11bf0a4e/a2b1d75d/dc85ca56/71c63294/dog.webp') }) })