How to use createPage method in storybook-root

Best JavaScript code snippet using storybook-root

gatsby-pagination.spec.js

Source:gatsby-pagination.spec.js Github

copy

Full Screen

1import { createPaginationPages } from "../index";2import { prefixPathFormatter } from "../index";3import { createLinkedPages } from "../index";4const buildMock = () => jest.fn().mockImplementation(value => value);5const buildEdgeSet = (size, obj = {}) =>6 Array.from(Array(size), (_, x) => JSON.parse(JSON.stringify(obj)));7const runEdgeTest = () => {8 const edges = buildEdgeSet(7);9 const createPage = buildMock();10 createPaginationPages({11 edges: edges,12 createPage: createPage,13 component: "component",14 limit: 215 });16 return createPage;17};18describe(`gatsby-pagination`, () => {19 describe(`createPaginatedPages`, () => {20 test("should generate Gatsby pages, defaulting to 10 items per page", () => {21 const edges = buildEdgeSet(30);22 const createPage = buildMock();23 const expected = 3;24 createPaginationPages({25 edges: edges,26 createPage: createPage,27 component: "component"28 });29 expect(createPage.mock.calls.length).toBe(expected); // inferred by calls to createPage30 });31 test("should allow a custom number of posts per page.", () => {32 let i = 1;33 const edges = buildEdgeSet(8).map(obj => ({ post: i++ }));34 const createPage = buildMock();35 createPaginationPages({36 edges: edges,37 createPage: createPage,38 component: "component",39 limit: 540 });41 expect(createPage.mock.calls.length).toBe(2); // inferred by calls to createPage42 expect(createPage.mock.calls[0][0].context).toMatchObject({43 limit: 5,44 next: "/2",45 nodes: [46 { post: 1 },47 { post: 2 },48 { post: 3 },49 { post: 4 },50 { post: 5 }51 ],52 page: 1,53 pages: 2,54 total: 855 });56 expect(createPage.mock.calls[1][0].context).toMatchObject({57 limit: 5,58 nodes: [{ post: 6 }, { post: 7 }, { post: 8 }],59 page: 2,60 pages: 2,61 prev: "/",62 total: 863 });64 });65 test("should format first pages as blank index page, not with a number", () => {66 const expected = "/";67 const notExpected = "/1";68 const createPage = runEdgeTest();69 expect(createPage.mock.calls[0][0].path).toBe(expected);70 expect(createPage.mock.calls[0][0].path).not.toBe(notExpected);71 });72 test("should start counting pages with second page, e.g. page 2", () => {73 const expected = "/2";74 const createPage = runEdgeTest();75 expect(createPage.mock.calls[1][0].path).toBe(expected);76 });77 test("should providing next property when there are multiple pages", () => {78 const createPage = runEdgeTest();79 expect(createPage.mock.calls[0][0].context.next).toBeDefined();80 expect(createPage.mock.calls[0][0].context.next).toBe("/2");81 expect(createPage.mock.calls[1][0].context.next).toBeDefined();82 expect(createPage.mock.calls[1][0].context.next).toBe("/3");83 expect(createPage.mock.calls[2][0].context.next).toBeDefined();84 expect(createPage.mock.calls[2][0].context.next).toBe("/4");85 expect(createPage.mock.calls[3][0].context.next).not.toBeDefined();86 });87 test("should providing prev property when there are multiple pages", () => {88 const createPage = runEdgeTest();89 expect(createPage.mock.calls[0][0].context.prev).not.toBeDefined();90 expect(createPage.mock.calls[1][0].context.prev).toBeDefined();91 expect(createPage.mock.calls[1][0].context.prev).toBe("/");92 expect(createPage.mock.calls[2][0].context.prev).toBeDefined();93 expect(createPage.mock.calls[2][0].context.prev).toBe("/2");94 expect(createPage.mock.calls[3][0].context.prev).toBeDefined();95 expect(createPage.mock.calls[3][0].context.prev).toBe("/3");96 });97 test("should allow option to create custom paths based on page number", () => {98 const edges = buildEdgeSet(30);99 const createPage = buildMock();100 const expected = "/custom/path/2";101 createPaginationPages({102 edges: edges,103 createPage: createPage,104 component: "component",105 pathFormatter: pageNumber => `/custom/path/${pageNumber}`106 });107 expect(createPage.mock.calls[1][0].path).toBe(expected);108 });109 test("should allow the custom component to be used", () => {110 const edges = buildEdgeSet(30);111 const createPage = buildMock();112 const expected = "MyComponent";113 createPaginationPages({114 edges: edges,115 createPage: createPage,116 component: "MyComponent"117 });118 expect(createPage.mock.calls[0][0].component).toBe(expected);119 });120 test("should allow custom context to be used", () => {121 const edges = buildEdgeSet(7);122 const createPage = buildMock();123 createPaginationPages({124 edges: edges,125 createPage: createPage,126 component: "component",127 limit: 2,128 context: { foo: "bar" }129 });130 expect(createPage.mock.calls[0][0].context.foo).toBeDefined();131 expect(createPage.mock.calls[0][0].context.foo).toBe("bar");132 expect(createPage.mock.calls[1][0].context.foo).toBeDefined();133 expect(createPage.mock.calls[1][0].context.foo).toBe("bar");134 expect(createPage.mock.calls[2][0].context.foo).toBeDefined();135 expect(createPage.mock.calls[2][0].context.foo).toBe("bar");136 expect(createPage.mock.calls[3][0].context.foo).toBeDefined();137 expect(createPage.mock.calls[3][0].context.foo).toBe("bar");138 });139 });140 describe(`prefixPathFormatter`, () => {141 describe(`should allow users to append a prefix before paginated page paths`, () => {142 test("should return paths appended with prefix", () => {143 expect(prefixPathFormatter).not.toBeUndefined();144 const edges = buildEdgeSet(1);145 const createPage = buildMock();146 const expected = {147 component: "component",148 context: {149 limit: 10,150 nodes: edges,151 page: 1,152 pages: 1,153 total: 1154 },155 path: "prefix/"156 };157 createPaginationPages({158 edges: edges,159 createPage: createPage,160 component: "component",161 pathFormatter: prefixPathFormatter("prefix")162 });163 expect(createPage.mock.calls.length).toBe(1);164 expect(createPage.mock.calls[0].length).toBe(1);165 expect(createPage.mock.calls[0][0]).toMatchObject(expected);166 });167 });168 });169 const runCreateLinkedPages = edges => {170 const createPage = buildMock();171 const edgeParser = edge => ({172 path: `/${edge.node.fields.slug}`,173 context: {174 slug: edge.node.fields.slug175 }176 });177 createLinkedPages({178 edges: edges,179 createPage: createPage,180 component: "MyComponent",181 edgeParser: edgeParser182 });183 return createPage;184 };185 describe(`createLinkedPages`, () => {186 test("should call createdPage for each edge and provide `prev` via the context if previous page is exists)", () => {187 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });188 edges[0].node.fields.slug = "a";189 edges[1].node.fields.slug = "b";190 edges[2].node.fields.slug = "c";191 const createPage = runCreateLinkedPages(edges);192 expect(createPage.mock.calls[0][0].context.prev).not.toBeDefined();193 expect(createPage.mock.calls[1][0].context.prev).toBe(`/a`);194 expect(createPage.mock.calls[2][0].context.prev).toBe(`/b`);195 });196 test("should call createdPage for each edge and provide `next` via the context if next page is exists)", () => {197 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });198 edges[0].node.fields.slug = "a";199 edges[1].node.fields.slug = "b";200 edges[2].node.fields.slug = "c";201 const createPage = runCreateLinkedPages(edges);202 expect(createPage.mock.calls[0][0].context.next).toBe("/b");203 expect(createPage.mock.calls[1][0].context.next).toBe("/c");204 expect(createPage.mock.calls[2][0].context.next).not.toBeDefined();205 });206 const runCreateLinkedPagesAndEnableCircular = edges => {207 const createPage = buildMock();208 const edgeParser = edge => ({209 path: `/${edge.node.fields.slug}`,210 context: {211 slug: edge.node.fields.slug212 }213 });214 createLinkedPages({215 edges: edges,216 createPage: createPage,217 component: "MyComponent",218 edgeParser: edgeParser,219 circular: true220 });221 return createPage;222 };223 test("should support circular option to link the first and last nodes.", () => {224 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });225 edges[0].node.fields.slug = "a";226 edges[1].node.fields.slug = "b";227 edges[2].node.fields.slug = "c";228 const createPage = runCreateLinkedPagesAndEnableCircular(edges);229 expect(createPage.mock.calls[0][0].context.prev).toBe("/c");230 expect(createPage.mock.calls[2][0].context.next).toBe("/a");231 });232 test("should call createdPage for each edge and provide `total` via the context", () => {233 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });234 edges[0].node.fields.slug = "a";235 edges[1].node.fields.slug = "b";236 edges[2].node.fields.slug = "c";237 const createPage = runCreateLinkedPages(edges);238 expect(createPage.mock.calls[0][0].context.total).toBe(3);239 expect(createPage.mock.calls[1][0].context.total).toBe(3);240 expect(createPage.mock.calls[2][0].context.total).toBe(3);241 });242 test("should allow the custom component to be used", () => {243 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });244 edges[0].node.fields.slug = "a";245 edges[1].node.fields.slug = "b";246 edges[2].node.fields.slug = "c";247 const expected = "MyComponent";248 const createPage = runCreateLinkedPages(edges);249 expect(createPage.mock.calls[0][0].component).toBe(expected);250 });251 test("should allow th ability for each page's path to be set", () => {252 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });253 edges[0].node.fields.slug = "a";254 edges[1].node.fields.slug = "b";255 edges[2].node.fields.slug = "c";256 const createPage = runCreateLinkedPages(edges);257 expect(createPage.mock.calls[0][0].path).toBe("/a");258 expect(createPage.mock.calls[1][0].path).toBe("/b");259 expect(createPage.mock.calls[2][0].path).toBe("/c");260 });261 test("should allow the ability to set each page's context", () => {262 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });263 edges[0].node.fields.slug = "a";264 edges[1].node.fields.slug = "b";265 edges[2].node.fields.slug = "c";266 const createPage = runCreateLinkedPages(edges);267 expect(createPage.mock.calls[0][0].context.slug).toBe("a");268 expect(createPage.mock.calls[1][0].context.slug).toBe("b");269 expect(createPage.mock.calls[2][0].context.slug).toBe("c");270 });271 const runCreateLinkedPagesAndSetLayout = edges => {272 const createPage = buildMock();273 const edgeParser = edge => ({274 path: `/${edge.node.fields.slug}`,275 context: {276 slug: edge.node.fields.slug277 },278 layout:279 edge.node.fields.slug === "b"280 ? undefined281 : `layout.${edge.node.fields.slug}`282 });283 createLinkedPages({284 edges: edges,285 createPage: createPage,286 component: "MyComponent",287 edgeParser: edgeParser288 });289 return createPage;290 };291 test("should allow the ability to set each page's layout", () => {292 const edges = buildEdgeSet(3, { node: { fields: { slug: "" } } });293 edges[0].node.fields.slug = "a";294 edges[1].node.fields.slug = "b";295 edges[2].node.fields.slug = "c";296 const createPage = runCreateLinkedPagesAndSetLayout(edges);297 expect(createPage.mock.calls[0][0].layout).toBe("layout.a");298 expect(createPage.mock.calls[1][0].layout).not.toBeDefined();299 expect(createPage.mock.calls[2][0].layout).toBe("layout.c");300 });301 });...

Full Screen

Full Screen

linked-page-builder.test.js

Source:linked-page-builder.test.js Github

copy

Full Screen

1import LinkedPageBuilder from "../linked-page-builder";2import PaginationPageBuilder from "../pagination-page-builder";3const buildMock = () => jest.fn().mockImplementation(value => value);4const buildEdgeSet = (size, obj = {}) =>5 Array.from(Array(size), (_, x) => Object.assign({}, obj));6describe(`LinkedPageBuilder`, () => {7 test("shuold be require-able", () => {8 expect(LinkedPageBuilder).not.toBeUndefined();9 });10 test("should instantiate", () => {11 const createPage = () => "";12 const edges = [];13 const component = "component";14 const paramsFormatter = () => {15 path: "/";16 };17 const instance = new LinkedPageBuilder(18 createPage,19 edges,20 component,21 paramsFormatter22 );23 expect(instance).not.toBeUndefined();24 });25 describe(`constructor`, () => {26 test("should error if missing 'createPage'", () => {27 const createPage = () => "";28 const edges = [];29 const component = "component";30 const paramsFormatter = () => {31 path: "/";32 };33 const expected = "Argument `createPage` must be provided.";34 expect(35 () => new LinkedPageBuilder(null, edges, component, paramsFormatter)36 ).toThrowError(expected);37 });38 test("should error if missing 'edges'", () => {39 const createPage = () => "";40 const edges = [];41 const component = "component";42 const paramsFormatter = () => {43 path: "/";44 };45 const expected = "Argument `edges` must be provided.";46 expect(47 () =>48 new LinkedPageBuilder(createPage, null, component, paramsFormatter)49 ).toThrowError(expected);50 });51 test("should error if missing 'component'", () => {52 const createPage = () => "";53 const edges = [];54 const paramsFormatter = () => {55 path: "/";56 };57 const expected = "Argument `component` must be provided.";58 expect(59 () => new LinkedPageBuilder(createPage, edges, null, paramsFormatter)60 ).toThrowError(expected);61 });62 test("should error if missing 'edgeParser'", () => {63 const createPage = () => "";64 const edges = [];65 const component = "component";66 const expected = "Argument `edgeParser` must be provided.";67 expect(68 () => new LinkedPageBuilder(createPage, edges, component, null)69 ).toThrowError(expected);70 });71 });72 describe(`setLooping`, () => {73 test("should have method", () => {74 const createPage = buildMock();75 const edges = ["a", "b", "c"];76 const component = "component";77 const paramsFormatter = jest.fn().mockImplementation(edge => ({78 path: `/${edge}`79 }));80 const instance = new LinkedPageBuilder(81 createPage,82 edges,83 component,84 paramsFormatter85 );86 expect(instance.setCircular).not.toBeUndefined();87 });88 test("should be chainable method", () => {89 const createPage = buildMock();90 const edges = ["a", "b", "c"];91 const component = "component";92 const paramsFormatter = jest.fn().mockImplementation(edge => ({93 path: `/${edge}`94 }));95 const instance = new LinkedPageBuilder(96 createPage,97 edges,98 component,99 paramsFormatter100 )101 .setCircular(true)102 .setCircular(false);103 });104 });105 describe(`build`, () => {106 test("should have method", () => {107 const createPage = buildMock();108 const edges = ["a", "b", "c"];109 const component = "component";110 const paramsFormatter = jest.fn().mockImplementation(edge => ({111 path: `/${edge}`112 }));113 const instance = new LinkedPageBuilder(114 createPage,115 edges,116 component,117 paramsFormatter118 );119 expect(instance.build).not.toBeUndefined();120 });121 test("should call edgeParser with the value of each edge", () => {122 const createPage = buildMock();123 const edges = ["a", "b", "c"];124 const component = "component";125 const paramsFormatter = jest.fn().mockImplementation(edge => ({126 path: `/${edge}`127 }));128 const instance = new LinkedPageBuilder(129 createPage,130 edges,131 component,132 paramsFormatter133 ).build();134 expect(paramsFormatter.mock.calls.length).toBe(edges.length);135 expect(paramsFormatter.mock.calls[0][0]).toBe(edges[0]);136 expect(paramsFormatter.mock.calls[1][0]).toBe(edges[1]);137 expect(paramsFormatter.mock.calls[2][0]).toBe(edges[2]);138 });139 test("should call createPage for each edge", () => {140 const createPage = buildMock();141 const edges = ["a", "b", "c"];142 const component = "component";143 const paramsFormatter = jest.fn().mockImplementation(edge => ({144 path: `/${edge}`145 }));146 new LinkedPageBuilder(147 createPage,148 edges,149 component,150 paramsFormatter151 ).build();152 expect(createPage.mock.calls.length).toBe(edges.length);153 });154 test("should call createPage with expected output from edgeParser", () => {155 const createPage = buildMock();156 const edges = ["a", "b", "c"];157 const component = "component";158 const paramsFormatter = jest.fn().mockImplementation(edge => ({159 path: `/${edge}`160 }));161 new LinkedPageBuilder(162 createPage,163 edges,164 component,165 paramsFormatter166 ).build();167 expect(createPage.mock.calls[0][0].path).toBe(`/${edges[0]}`);168 expect(createPage.mock.calls[1][0].path).toBe(`/${edges[1]}`);169 expect(createPage.mock.calls[2][0].path).toBe(`/${edges[2]}`);170 });171 test("should call createPage with combined context data", () => {172 const createPage = buildMock();173 const edges = ["a", "b", "c"];174 const component = "component";175 const paramsFormatter = jest.fn().mockImplementation(edge => ({176 path: `/${edge}`,177 context: {178 data: "myData"179 }180 }));181 new LinkedPageBuilder(182 createPage,183 edges,184 component,185 paramsFormatter186 ).build();187 expect(createPage.mock.calls[0][0].context.data).toBe("myData");188 expect(createPage.mock.calls[1][0].context.data).toBe("myData");189 expect(createPage.mock.calls[2][0].context.data).toBe("myData");190 });191 test("should call createPage without layout only when included in edgeParser output", () => {192 const createPage = buildMock();193 const edges = ["a", "b", "c"];194 const component = "component";195 const paramsFormatter = jest.fn().mockImplementation(edge => ({196 path: `/${edge}`,197 context: {198 data: "myData"199 },200 layout: edge === "b" ? undefined : `layout.${edge}`201 }));202 new LinkedPageBuilder(203 createPage,204 edges,205 component,206 paramsFormatter207 ).build();208 expect(createPage.mock.calls[0][0].layout).toBe("layout.a");209 expect(createPage.mock.calls[1][0].layout).not.toBeDefined();210 expect(createPage.mock.calls[2][0].layout).toBe("layout.c");211 });212 test("should call createPage with expected `next` results when 'circular' is disabled", () => {213 const createPage = buildMock();214 const edges = ["a", "b", "c"];215 const component = "component";216 const paramsFormatter = jest.fn().mockImplementation(edge => ({217 path: `/${edge}`218 }));219 new LinkedPageBuilder(220 createPage,221 edges,222 component,223 paramsFormatter224 ).build();225 expect(createPage.mock.calls[0][0].context.next).toBe("/b");226 expect(createPage.mock.calls[1][0].context.next).toBe("/c");227 expect(createPage.mock.calls[2][0].context.next).not.toBeDefined();228 });229 test("should call createPage with expected `prev` results when 'circular' is disabled", () => {230 const createPage = buildMock();231 const edges = ["a", "b", "c"];232 const component = "component";233 const paramsFormatter = jest.fn().mockImplementation(edge => ({234 path: `/${edge}`235 }));236 new LinkedPageBuilder(237 createPage,238 edges,239 component,240 paramsFormatter241 ).build();242 expect(createPage.mock.calls[0][0].context.prev).not.toBeDefined();243 expect(createPage.mock.calls[1][0].context.prev).toBe("/a");244 expect(createPage.mock.calls[2][0].context.prev).toBe("/b");245 });246 test("should call createPage with expected `next` results when 'circular' is enabled", () => {247 const createPage = buildMock();248 const edges = ["a", "b", "c"];249 const component = "component";250 const paramsFormatter = jest.fn().mockImplementation(edge => ({251 path: `/${edge}`252 }));253 new LinkedPageBuilder(createPage, edges, component, paramsFormatter)254 .setCircular(true)255 .build();256 expect(createPage.mock.calls[0][0].context.next).toBe("/b");257 expect(createPage.mock.calls[1][0].context.next).toBe("/c");258 expect(createPage.mock.calls[2][0].context.next).toBe("/a");259 });260 test("should call createPage with expected `prev` results when 'circular' is enabled", () => {261 const createPage = buildMock();262 const edges = ["a", "b", "c"];263 const component = "component";264 const paramsFormatter = jest.fn().mockImplementation(edge => ({265 path: `/${edge}`266 }));267 new LinkedPageBuilder(createPage, edges, component, paramsFormatter)268 .setCircular(true)269 .build();270 expect(createPage.mock.calls[0][0].context.prev).toBe("/c");271 expect(createPage.mock.calls[1][0].context.prev).toBe("/a");272 expect(createPage.mock.calls[2][0].context.prev).toBe("/b");273 });274 test("should call createPage with expected `total` results", () => {275 const createPage = buildMock();276 const edges = ["a", "b", "c"];277 const component = "component";278 const paramsFormatter = jest.fn().mockImplementation(edge => ({279 path: `/${edge}`280 }));281 new LinkedPageBuilder(282 createPage,283 edges,284 component,285 paramsFormatter286 ).build();287 expect(createPage.mock.calls[0][0].context.total).toBe(3);288 expect(createPage.mock.calls[1][0].context.total).toBe(3);289 expect(createPage.mock.calls[2][0].context.total).toBe(3);290 });291 });...

Full Screen

Full Screen

create.js

Source:create.js Github

copy

Full Screen

1import createPageFactory from '../support/CreatePage';2import editPageFactory from '../support/EditPage';3import showPageFactory from '../support/ShowPage';4import loginPageFactory from '../support/LoginPage';5describe('Create Page', () => {6 const CreatePage = createPageFactory('/#/posts/create');7 const UserCreatePage = createPageFactory('/#/users/create');8 const ShowPage = showPageFactory('/#/posts/14/show');9 const EditPage = editPageFactory('/#/posts/14');10 const LoginPage = loginPageFactory('/#/login');11 beforeEach(() => {12 LoginPage.navigate();13 LoginPage.login('admin', 'password');14 CreatePage.navigate();15 });16 it('should show the correct title in the appBar', () => {17 cy.get(CreatePage.elements.title).contains('Create Post');18 });19 it('should put the current date in the field by default', () => {20 const currentDate = new Date();21 const currentDateString = currentDate.toISOString().slice(0, 10);22 cy.get(CreatePage.elements.input('published_at')).should(el =>23 expect(el).to.have.value(currentDateString)24 );25 });26 it('should put the ArrayInput default value', () => {27 const currentDate = new Date();28 const currentDateString = currentDate.toISOString().slice(0, 10);29 cy.get(CreatePage.elements.input('backlinks[0].date')).should(el =>30 expect(el).to.have.value(currentDateString)31 );32 cy.get(CreatePage.elements.input('backlinks[0].url')).should(el =>33 expect(el).to.have.value('http://google.com')34 );35 });36 it('should have a working array input with references', () => {37 cy.get(CreatePage.elements.addAuthor).click();38 cy.get(CreatePage.elements.input('authors[0].user_id')).should(39 el => expect(el).to.exist40 );41 cy.get(CreatePage.elements.input('authors[0].role')).should(42 el => expect(el).to.not.exist43 );44 });45 it('should have a working array input with a scoped FormDataConsumer', () => {46 cy.get(CreatePage.elements.addAuthor).click();47 CreatePage.setValues([48 {49 type: 'input',50 name: 'authors[0].user_id',51 value: 'Annamarie Mayer',52 },53 ]);54 cy.contains('Annamarie Mayer').click();55 cy.get(CreatePage.elements.input('authors[0].role')).should(56 el => expect(el).to.exist57 );58 });59 it('should redirect to edit page after create success', () => {60 const values = [61 {62 type: 'input',63 name: 'title',64 value: 'Test title',65 },66 {67 type: 'textarea',68 name: 'teaser',69 value: 'Test teaser',70 },71 {72 type: 'rich-text-input',73 name: 'body',74 value: 'Test body',75 },76 ];77 CreatePage.setValues(values);78 CreatePage.submit();79 EditPage.waitUntilVisible();80 cy.get(EditPage.elements.input('title')).should(el =>81 expect(el).to.have.value('Test title')82 );83 cy.get(EditPage.elements.input('teaser')).should(el =>84 expect(el).to.have.value('Test teaser')85 );86 EditPage.delete();87 });88 it('should redirect to show page after create success with "Save and show"', () => {89 const values = [90 {91 type: 'input',92 name: 'title',93 value: 'Test title',94 },95 {96 type: 'textarea',97 name: 'teaser',98 value: 'Test teaser',99 },100 {101 type: 'rich-text-input',102 name: 'body',103 value: 'Test body',104 },105 ];106 CreatePage.setValues(values);107 CreatePage.submitAndShow();108 ShowPage.waitUntilVisible();109 EditPage.navigate();110 EditPage.delete();111 });112 it('should stay at create page after create success with "Save and add"', () => {113 const values = [114 {115 type: 'input',116 name: 'title',117 value: 'Test title',118 },119 {120 type: 'textarea',121 name: 'teaser',122 value: 'Test teaser',123 },124 {125 type: 'rich-text-input',126 name: 'body',127 value: 'Test body',128 },129 ];130 CreatePage.setValues(values);131 CreatePage.submitAndAdd();132 cy.url().then(url => expect(url).to.contain('/#/posts/create'));133 cy.get(CreatePage.elements.input('title')).should(el =>134 expect(el).to.have.value('')135 ); // new empty form136 EditPage.navigate();137 EditPage.delete();138 });139 it('should allow to call a custom action updating values before submit', () => {140 const values = [141 {142 type: 'input',143 name: 'title',144 value: 'Test title',145 },146 {147 type: 'textarea',148 name: 'teaser',149 value: 'Test teaser',150 },151 {152 type: 'checkbox',153 name: 'commentable',154 value: false,155 },156 {157 type: 'rich-text-input',158 name: 'body',159 value: 'Test body',160 },161 ];162 CreatePage.setValues(values);163 CreatePage.submitWithAverageNote();164 ShowPage.waitUntilVisible();165 ShowPage.gotoTab(3);166 cy.contains('10');167 EditPage.navigate();168 EditPage.delete();169 });170 it('should not accept creation without required fields', () => {171 const values = [172 {173 type: 'textarea',174 name: 'teaser',175 value: 'Test teaser',176 },177 ];178 CreatePage.setValues(values);179 CreatePage.submit();180 cy.contains('Required field');181 });182 it('should not reset form values when an input with defaultValue is dynamically added', () => {183 const values = [184 {185 type: 'input',186 name: 'title',187 value: 'Test title',188 },189 ];190 CreatePage.setValues(values);191 cy.get(CreatePage.elements.input('average_note')).should(el =>192 expect(el).to.have.value('5')193 );194 cy.get(CreatePage.elements.input('title')).should(el =>195 expect(el).to.have.value('Test title')196 );197 });198 it('should not reset the form value when switching tabs', () => {199 LoginPage.navigate();200 LoginPage.login('admin', 'password');201 UserCreatePage.navigate();202 CreatePage.setValues([203 {204 type: 'input',205 name: 'name',206 value: 'The real Slim Shady!',207 },208 ]);209 CreatePage.gotoTab(2);210 CreatePage.gotoTab(1);211 cy.get(CreatePage.elements.input('name')).should(el =>212 expect(el).to.have.value('The real Slim Shady!')213 );214 });215 it('should not show rich text input error message when field is untouched', () => {216 cy.get(CreatePage.elements.richTextInputError).should('not.exist');217 });218 it('should show rich text input error message when form is submitted', () => {219 CreatePage.submit();220 cy.get(CreatePage.elements.richTextInputError)221 .should('exist')222 .contains('Required');223 });224 it('should not show rich text input error message when form is submitted and input is filled with text', () => {225 CreatePage.submit();226 cy.get(CreatePage.elements.richTextInputError)227 .should('exist')228 .contains('Required');229 cy.get(CreatePage.elements.input('body', 'rich-text-input')).type(230 'text'231 );232 cy.get(CreatePage.elements.richTextInputError).should('not.exist');233 });234 it('should show body in edit view after creating new post', () => {235 const values = [236 {237 type: 'input',238 name: 'title',239 value: 'Test title',240 },241 {242 type: 'textarea',243 name: 'teaser',244 value: 'Test teaser',245 },246 {247 type: 'rich-text-input',248 name: 'body',249 value: 'Test body',250 },251 ];252 CreatePage.setValues(values);253 CreatePage.submit();254 EditPage.gotoTab(2);255 cy.get(EditPage.elements.input('body', 'rich-text-input')).contains(256 'Test body'257 );258 });...

Full Screen

Full Screen

pagination-page-builder.test.js

Source:pagination-page-builder.test.js Github

copy

Full Screen

1import PaginationPageBuilder from "../pagination-page-builder";2describe(`PaginationPageBuilder`, () => {3 const buildMock = () => jest.fn().mockImplementation(value => value);4 const buildEdgeSet = (size, obj = {}) =>5 Array.from(Array(size), (_, x) => Object.assign({}, obj));6 const createPaginationPageBuilder = () => {7 const createPage = () => "";8 const edges = [];9 const component = "component";10 return new PaginationPageBuilder(createPage, edges, component);11 };12 test("should be require-able", () => {13 expect(PaginationPageBuilder).toBeTruthy();14 });15 test("should be constructable", () => {16 const createPage = () => "";17 const edges = [];18 const component = "component";19 const layout = "layout";20 expect(21 new PaginationPageBuilder(createPage, edges, component, layout)22 ).toBeDefined();23 });24 test("should error if missing createPage", () => {25 const createPage = () => "";26 const edges = [];27 const component = "component";28 const expected = "Argument `createPage` must be provided.";29 expect(30 () => new PaginationPageBuilder(null, edges, component)31 ).toThrowError(expected);32 });33 test("should error if missing edges", () => {34 const createPage = () => "";35 const edges = [];36 const component = "component";37 const expected = "Argument `edges` must be provided.";38 expect(39 () => new PaginationPageBuilder(createPage, null, component)40 ).toThrowError(expected);41 });42 test("should error if missing component", () => {43 const createPage = () => "";44 const edges = [];45 const expected = "Argument `component` must be provided.";46 expect(47 () => new PaginationPageBuilder(createPage, edges, null)48 ).toThrowError(expected);49 });50 describe(`setLimit`, () => {51 test("should have method", () => {52 const instance = createPaginationPageBuilder();53 expect(instance.setLimit).not.toBeUndefined();54 });55 test("should take a number", () => {56 const instance = createPaginationPageBuilder();57 const input = 5;58 expect(instance.setLimit(input));59 });60 test("should override the default limit", () => {61 const createPage = buildMock();62 const edges = buildEdgeSet(100);63 const instance = new PaginationPageBuilder(64 createPage,65 edges,66 "component"67 );68 instance.setLimit(5);69 const expectedLimit = 5;70 const expectedPages = 20;71 instance.build();72 expect(createPage.mock.calls[0][0].context.limit).toBe(expectedLimit);73 expect(createPage.mock.calls[0][0].context.pages).toBe(expectedPages);74 });75 test("should be chainable", () => {76 const createPage = buildMock();77 const edges = buildEdgeSet(100);78 new PaginationPageBuilder(createPage, edges, "component")79 .setLimit(5)80 .build();81 });82 });83 describe(`setPathFormatter`, () => {84 test("should have method", () => {85 const instance = createPaginationPageBuilder();86 expect(instance.setPathFormatter).not.toBeUndefined();87 });88 test("should take a function", () => {89 const instance = createPaginationPageBuilder();90 const input = pageNumber => `/${pageNumber}`;91 expect(instance.setPathFormatter(input));92 });93 test("should override the default limit", () => {94 const createPage = buildMock();95 const pathFormatter = buildMock();96 const edges = buildEdgeSet(30);97 const instance = new PaginationPageBuilder(98 createPage,99 edges,100 "component"101 );102 instance.setPathFormatter(pathFormatter);103 const expectedCalls = 7; // 3 pages: 2 + 3 + 2104 instance.build();105 expect(pathFormatter.mock.calls.length).toBe(expectedCalls);106 });107 test("should be chainable", () => {108 const createPage = buildMock();109 const pathFormatter = buildMock();110 const edges = buildEdgeSet(30);111 new PaginationPageBuilder(createPage, edges, "component")112 .setPathFormatter(pathFormatter)113 .build();114 });115 });116 describe(`build`, () => {117 test("should have method", () => {118 const instance = createPaginationPageBuilder();119 expect(instance.build).not.toBeUndefined();120 });121 test("should execute", () => {122 const createPage = buildMock();123 const edges = buildEdgeSet(10);124 const instance = new PaginationPageBuilder(125 createPage,126 edges,127 "component"128 );129 instance.build();130 });131 test("should call createPage", () => {132 const createPage = buildMock();133 const edges = buildEdgeSet(10);134 const instance = new PaginationPageBuilder(135 createPage,136 edges,137 "component"138 );139 instance.build();140 expect(createPage.mock.calls.length).toBe(1);141 expect(createPage.mock.calls[0].length).toBe(1);142 });143 test("should call createPage with expected component", () => {144 const createPage = buildMock();145 const edges = buildEdgeSet(10);146 const instance = new PaginationPageBuilder(147 createPage,148 edges,149 "component"150 );151 const expected = "component";152 instance.build();153 expect(createPage.mock.calls[0][0].component).toBe(expected);154 });155 test("should call createPage with expected layout", () => {156 const createPage = buildMock();157 const edges = buildEdgeSet(10);158 const instance = new PaginationPageBuilder(159 createPage,160 edges,161 "component",162 "layout"163 );164 const expected = "layout";165 instance.build();166 expect(createPage.mock.calls[0][0].layout).toBe(expected);167 });168 test("should call createPage with expected path", () => {169 const createPage = buildMock();170 const edges = buildEdgeSet(10);171 const instance = new PaginationPageBuilder(172 createPage,173 edges,174 "component"175 );176 const expected = "/";177 instance.build();178 expect(createPage.mock.calls[0][0].path).toBe(expected);179 });180 test("should call createPage with expected context.nodes", () => {181 const createPage = buildMock();182 const edges = buildEdgeSet(10);183 const instance = new PaginationPageBuilder(184 createPage,185 edges,186 "component"187 );188 const expected = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];189 instance.build();190 expect(createPage.mock.calls[0][0].context.nodes).toMatchObject(expected);191 });192 test("should call createPage with expected context.page", () => {193 const createPage = buildMock();194 const edges = buildEdgeSet(10);195 const instance = new PaginationPageBuilder(196 createPage,197 edges,198 "component"199 );200 const expected = 1;201 instance.build();202 expect(createPage.mock.calls[0][0].context.page).toBe(expected);203 });204 test("should call createPage with expected context.pages", () => {205 const createPage = buildMock();206 const edges = buildEdgeSet(100);207 const instance = new PaginationPageBuilder(208 createPage,209 edges,210 "component"211 );212 const expected = 10;213 instance.build();214 expect(createPage.mock.calls[0][0].context.pages).toBe(expected);215 });216 test("should call createPage with expected context.total", () => {217 const createPage = buildMock();218 const edges = buildEdgeSet(100);219 const instance = new PaginationPageBuilder(220 createPage,221 edges,222 "component"223 );224 const expected = 100;225 instance.build();226 expect(createPage.mock.calls[0][0].context.total).toBe(expected);227 });228 });...

Full Screen

Full Screen

createPage.js

Source:createPage.js Github

copy

Full Screen

...34 storeCheck.page = page;35 }}36};37var pageController = proxyquire('../../../../lib/businessLayer/PageController.js', stub);38describe('TU3 - pageController.createPage()', function() {39 40 it('Should fail when called with no parameters - error 2000', function() {41 var check = true;42 try{43 pageController.createPage();44 } catch(e) {45 if(e === 2000)46 check = false;47 }48 check.should.be.exactly(false);49 });50 51 it('Should fail when called with inconsistent options - error 2004', function() {52 var check = true;53 try{54 pageController.createPage("page title", {inconsistent: "option"});55 } catch(e) {56 if(e === 2004)57 check = false;58 }59 check.should.be.exactly(false);60 });61 62 it('Should fail when called with invalid pageWidth option type - error 2002', function() {63 var check = true;64 try{65 pageController.createPage("page title", {pageWidth: "not a number"});66 } catch(e) {67 if(e === 2002)68 check = false;69 }70 check.should.be.exactly(false);71 });72 73 it('Should fail when called with invalid pageWidth option (<800) - error 2002', function() {74 var check = true;75 try{76 pageController.createPage("page title", {pageWidth: 700});77 } catch(e) {78 if(e === 2002)79 check = false;80 }81 check.should.be.exactly(false);82 });83 84 it('Should fail when called with invalid columns option type - error 2003', function() {85 var check = true;86 try{87 pageController.createPage("page title", {columns: "not a number"});88 } catch(e) {89 if(e === 2003)90 check = false;91 }92 check.should.be.exactly(false);93 });94 95 it('Should fail when called with invalid columns option (<1) - error 2003', function() {96 var check = true;97 try{98 pageController.createPage("page title", {columns: 0});99 } catch(e) {100 if(e === 2003)101 check = false;102 }103 check.should.be.exactly(false);104 });105 106 it('Should fail when called with invalid columns option (>12) - error 2003', function() {107 var check = true;108 try{109 pageController.createPage("page title", {columns: 13});110 } catch(e) {111 if(e === 2003)112 check = false;113 }114 check.should.be.exactly(false);115 });116 117 it('Should execute correctly when called without options', function() {118 pageController.createPage("valid title");119 should.exist(storeCheck);120 should.exist(storeCheck.page);121 storeCheck.id.should.be.exactly(2);122 should.exist(modelStub);123 modelStub.id.should.be.exactly(2);124 modelStub.title.should.be.exactly("valid title");125 modelStub.pageWidth.should.be.exactly(0);126 modelStub.columns.should.be.exactly(2);127 });128 129});130describe('TU7 - pageController.createPage()', function() {131 132 it('Should execute correctly when called with valid pageWidth option', function() {133 pageController.createPage("another valid title", {pageWidth: 1920});134 should.exist(storeCheck);135 should.exist(storeCheck.page);136 storeCheck.id.should.be.exactly(2);137 should.exist(modelStub);138 modelStub.id.should.be.exactly(2);139 modelStub.title.should.be.exactly("another valid title");140 modelStub.pageWidth.should.be.exactly(1920);141 modelStub.columns.should.be.exactly(2);142 });143 144});145describe('TU10 - pageController.createPage()', function() {146 147 it('Should execute correctly when called with valid columns option', function() {148 pageController.createPage("another valid title", {columns: 12});149 should.exist(storeCheck);150 should.exist(storeCheck.page);151 storeCheck.id.should.be.exactly(2);152 should.exist(modelStub);153 modelStub.id.should.be.exactly(2);154 modelStub.title.should.be.exactly("another valid title");155 modelStub.pageWidth.should.be.exactly(0);156 modelStub.columns.should.be.exactly(12);157 });158 159});160describe('TU20 - PageController.createPage()', function() {161 162 it('Should execute correctly when a correct value for columns is given (between 1 and 12)', function() 163 {164 var errCheck = false;165 try {166 pageController.createPage("title", {columns: 4});167 } catch(err) {168 errCheck = true;169 }170 errCheck.should.be.false;171 should.exist(storeCheck);172 should.exist(storeCheck.page);173 storeCheck.id.should.be.exactly(2);174 should.exist(modelStub);175 modelStub.id.should.be.exactly(2);176 modelStub.title.should.be.exactly("title");177 modelStub.columns.should.be.exactly(4);178 }),179 180 it('Should set the default columns value (2) when no columns option is given', function() 181 {182 var errCheck = false;183 try {184 pageController.createPage("title");185 } catch(err) {186 errCheck = true;187 }188 errCheck.should.be.false;189 should.exist(storeCheck);190 should.exist(storeCheck);191 should.exist(storeCheck.page);192 storeCheck.id.should.be.exactly(2);193 should.exist(modelStub);194 modelStub.id.should.be.exactly(2);195 modelStub.title.should.be.exactly("title");196 modelStub.columns.should.be.exactly(2);197 }),198 199 it('Should throw error \'2003\' when the columns option given is not a number', function() 200 {201 var errCheck = false;202 var errNum = undefined;203 try {204 pageController.createPage("title", {columns: "this is not a number"});205 } catch(err) {206 errCheck = true;207 errNum = err;208 }209 errCheck.should.be.true;210 should.exist(errNum);211 errNum.should.be.exactly(2003);212 }),213 214 it('Should throw error \'2003\' when the columns option given is <1', function() 215 {216 var errCheck = false;217 var errNum = undefined;218 try {219 pageController.createPage("title", {columns: 0});220 } catch(err) {221 errCheck = true;222 errNum = err;223 }224 errCheck.should.be.true;225 should.exist(errNum);226 errNum.should.be.exactly(2003);227 }),228 229 it('Should throw error \'2003\' when the columns option given is >12', function() 230 {231 var errCheck = false;232 var errNum = undefined;233 try {234 pageController.createPage("title", {columns: 15});235 } catch(err) {236 errCheck = true;237 errNum = err;238 }239 errCheck.should.be.true;240 should.exist(errNum);241 errNum.should.be.exactly(2003);242 });...

Full Screen

Full Screen

pages.test.js

Source:pages.test.js Github

copy

Full Screen

1const {2 sessionPages,3 pagesFromMarkdown,4 sessionSearchPage,5} = require("./pages")6const samples = require("../../__mocks__/samples")7const createPage = jest.fn()8const reporter = {9 info: () => {},10}11describe("When the static pages are generated", () => {12 beforeEach(() => {13 jest.resetAllMocks()14 jest.clearAllMocks()15 })16 describe("The creation of the session pages", () => {17 const nodesWithSessions = [18 {19 upcomingSessions: null,20 sessions: null,21 },22 {23 upcomingSessions: [{ id: "66" }],24 sessions: null,25 },26 {27 upcomingSessions: null,28 sessions: null,29 },30 {31 upcomingSessions: null,32 sessions: [{ id: "65" }, { id: "64" }, { id: "63" }],33 },34 ]35 it("should filter out null values and build paths with IDs", () => {36 sessionPages({ nodes: nodesWithSessions }, createPage, reporter)37 expect(createPage).toHaveBeenCalledTimes(4)38 expect(createPage).toHaveBeenCalledWith({39 path: "/sessions/66",40 component: expect.stringMatching(/templates(.)+session-layout\.tsx/g),41 context: { id: "66" },42 })43 expect(createPage).toHaveBeenCalledWith({44 path: "/sessions/63",45 component: expect.stringMatching(/templates(.)+session-layout\.tsx/g),46 context: { id: "63" },47 })48 })49 it("should render the special template when no upcoming session exists", () => {50 const nodes = [51 {52 upcomingSessions: [{ id: "none" }],53 sessions: null,54 },55 {56 upcomingSessions: null,57 sessions: null,58 },59 ]60 sessionPages({ nodes }, createPage, reporter)61 expect(createPage).toHaveBeenCalledTimes(1)62 expect(createPage).toHaveBeenCalledWith({63 path: "/sessions/none",64 component: expect.stringMatching(65 /templates(.)+no-upcoming-layout\.tsx/g66 ),67 context: { id: "none" },68 })69 })70 it("should add the all sessions with content to a search template", () => {71 const allSessions = [72 {73 upcomingSessions: [{ id: "none" }],74 sessions: null,75 },76 ...nodesWithSessions,77 ]78 sessionSearchPage({ nodes: allSessions }, createPage, reporter)79 expect(createPage).toHaveBeenCalledTimes(1)80 expect(createPage).toHaveBeenCalledWith({81 path: "/search",82 component: expect.stringMatching(/templates(.)+search-layout\.tsx/g),83 context: expect.objectContaining({84 allSessions: [{ id: "66" }, { id: "65" }, { id: "64" }, { id: "63" }],85 options: {86 indexStrategy: "Prefix match",87 searchSanitizer: "Lower Case",88 TitleIndex: true,89 DescriptionIndex: true,90 TagIndex: true,91 SearchByTerm: true,92 },93 }),94 })95 })96 })97 describe("The creation of pages from markdown", () => {98 it("should generate heuristics and GitHub pages", () => {99 let heuristicPageCounter = 0100 let githubPageCounter = 0101 createPage.mockImplementation(({ component }) => {102 if (component.indexOf("heuristic-layout.tsx") > 0)103 heuristicPageCounter += 1104 if (component.indexOf("github-repo-layout.tsx") > 0)105 githubPageCounter += 1106 })107 pagesFromMarkdown(samples.allMdx, createPage, reporter)108 expect(createPage).toHaveBeenCalledTimes(38)109 expect(heuristicPageCounter).toEqual(1)110 expect(githubPageCounter).toEqual(37)111 })112 })113 describe("The creation of the gitHub pages", () => {114 it("should filter out License files", () => {115 pagesFromMarkdown({ edges: samples.licenceMdxNode }, createPage, reporter)116 expect(createPage).toHaveBeenCalledTimes(0)117 })118 it("should generate entry pages from README files", () => {119 pagesFromMarkdown({ edges: samples.readmeMdxNodes }, createPage, reporter)120 expect(createPage).toHaveBeenCalledTimes(2)121 expect(createPage).toHaveBeenCalledWith({122 path: "/learning-ddd/ddd-crew-welcome-to-ddd",123 component: expect.stringMatching(124 /templates(.)+github-repo-layout\.tsx/g125 ),126 context: { id: "0120c7eb-b769-5f70-b487-5340c0a1b717" },127 })128 expect(createPage).toHaveBeenCalledWith({129 path: "/learning-ddd/saturn2019-architecture-island-workshop/outcomes",130 component: expect.stringMatching(131 /templates(.)+github-repo-layout\.tsx/g132 ),133 context: { id: "b2a05e2d-7dfe-5816-b603-cf3a900a8932" },134 })135 })136 it("should keep the name and the reference for non-readme files", () => {137 pagesFromMarkdown({ edges: samples.nonRootMdxNode }, createPage, reporter)138 expect(createPage).toHaveBeenCalledWith({139 path:140 "/learning-ddd/ddd-crew-bounded-context-canvas/tools/html-version/instructions.md",141 component: expect.any(String),142 context: { id: "52adaef0-a54c-506c-9168-22fd6a9bedd5" },143 })144 })145 it("should keep the name and the reference for deep references too", () => {146 pagesFromMarkdown(147 { edges: samples.deepResourceNode },148 createPage,149 reporter150 )151 expect(createPage).toHaveBeenCalledWith({152 path:153 "/learning-ddd/ddd-crew-bounded-context-canvas/resources/model-traits-worksheet-FR.md",154 component: expect.any(String),155 context: { id: "c9456f4e-80ef-583a-984f-8fd3c703cb15" },156 })157 })158 })159 describe("The creation of the heuristic pages", () => {160 it("should use the right path, template and context", () => {161 pagesFromMarkdown(162 { edges: samples.heuristicMdxNode },163 createPage,164 reporter165 )166 expect(createPage).toHaveBeenCalledWith({167 path:168 "/patterns-and-heuristics/heuristics/design-heuristics/eventstorming-dont-fill-in-the-gaps",169 component: expect.stringMatching(/templates(.)+heuristic-layout\.tsx/g),170 context: {171 id: "a968a5ee-d1ff-5821-aff9-bd7284921428",172 name: "eventstorming-dont-fill-in-the-gaps",173 },174 })175 })176 })...

Full Screen

Full Screen

EventCreateModalOld.js

Source:EventCreateModalOld.js Github

copy

Full Screen

1import $ from 'jquery';2import 'bootstrap/js/modal';3import FormHandles from '../Utils/FormHandles';4import { createDatetimePicker } from '../Widget/DateTimePicker';5import { createColorPicker } from '../Widget/ColorPicker';6import EventModal from './EventModalOld';7export default class EventCreateModal extends EventModal {8 constructor(args) {9 super(args);10 //TODO: 想办法避免导出全局变量11 window.g_createModal = this;12 };13 update(args) {14 this.resetFormInput(this.modal, '#tc-createpage-eventstart,#tc-createpage-eventend');15 super.update(args);16 };17 renderTemplate() {18 // 渲染 DOM19 this.renderFormComponent(this.modal, [20 {21 node: this.modal,22 eventName: 'shown.bs.modal',23 handle: () => this.modal.find('#tc-createpage-eventtitle').focus(),24 },25 {26 node: '#tc-createpage-eventstart',27 value: this.args.start.format('YYYY-MM-DD HH:mm:ss'),28 renderer: createDatetimePicker29 },30 {31 node: '#tc-createpage-eventend',32 value: this.args.end.format('YYYY-MM-DD HH:mm:ss'),33 renderer: createDatetimePicker34 },35 {36 node: '#tc-createpage-eventcolor',37 value: '',38 renderer: createColorPicker39 },40 {41 node: '#tc-createpage-create',42 eventName: 'click',43 handle: () => new FormHandles().onCreateBtnClick(this.args.start, this.args.end, this.args.jsEvent, this.args.view, this.modal),44 },45 {46 node: '#tc-createpage-cancel,#tc-createpage-close',47 eventName: 'click',48 handle: () => $('#calendar').fullCalendar('unselect')49 }50 ]);51 };52 get HtmlModalTemplate() {53 return `54 <div class="modal fade" tabindex="-1" role="dialog" id="tc-EventCreateModal" aria-labelledby="tc-createpage-dialogtitle">55 <div class="modal-dialog modal-dialog-centered" role="document">56 <div class="modal-content">57 <div class="modal-header">58 <button id='tc-createpage-close' type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>59 <h4 class="modal-title" id='tc-createpage-dialogtitle'>创建新的日程</h4>60 </div> 61 <div class="modal-body">62 <form>63 <div class="row">64 <div class='form-group col-md-12'>65 <label for="tc-createpage-eventtitle">标题</label>66 <input type="text" class="form-control eventtitle" id="tc-createpage-eventtitle">67 </div>68 </div>69 <div class="row">70 <div class="form-group col-md-6">71 <label for="tc-createpage-eventstart" class="col-form-label">开始日期</label>72 <input type="text" class="form-control datetimepicker-input eventstart" id="tc-createpage-eventstart" data-toggle="datetimepicker" data-target="#tc-createpage-eventstart" readonly/>73 </div>74 <div class="form-group col-md-6">75 <label for="tc-createpage-eventend" class="col-form-label">结束日期</label>76 <input type='text' class="form-control eventend" id='tc-createpage-eventend' readonly/>77 </div>78 </div>79 <div class="row">80 <div class="form-group col-md-6">81 <label for="tc-createpage-eventcolor" class="col-form-label">色彩</label>82 <input id="tc-createpage-eventcolor" class="form-control eventcolor" >83 </div>84 <div class="form-group col-md-6">85 <label for="tc-createpage-eventtags" class="col-form-label">标签</label>86 <input id="tc-createpage-eventtags" class="form-control eventtags" > 87 </div>88 </div>89 <div class="row">90 <div class='form-group col-md-12'>91 <label for="tc-createpage-eventremark">备注</label>92 <textarea class="form-control eventremark" id="tc-createpage-eventremark" rows="3"></textarea>93 </div>94 </div>95 </form>96 </div>97 <div class="modal-footer">98 <div class='row'>99 <div class='col-xs-12' >100 <button id='tc-createpage-create' class="btn btn-success" type="button">创建</button> 101 <button id='tc-createpage-cancel' type="button" class="btn btn-default" data-dismiss="modal">取消</button>102 </div>103 </div>104 </div>105 </div>106 </div>107 </div>108 `109 }...

Full Screen

Full Screen

gatsby-node.js

Source:gatsby-node.js Github

copy

Full Screen

1async function createLifeStory(createPage, graphql, reporter) {2 const pageTemplate = require.resolve(`./src/templates/life-story.js`);3 createPage({4 path: "life-story",5 component: pageTemplate,6 context: {7 slug: "life-story",8 },9 });10}11async function createBooks(createPage, graphql, reporter) {12 const pageTemplate = require.resolve(`./src/templates/books.js`);13 createPage({14 path: "books",15 component: pageTemplate,16 context: {},17 });18}19async function createEvents(createPage, graphql, reporter) {20 const pageTemplate = require.resolve(`./src/templates/events.js`);21 createPage({22 path: "events",23 component: pageTemplate,24 context: {},25 });26}27async function createMedia(createPage, graphql, reporter) {28 const pageTemplate = require.resolve(`./src/templates/media.js`);29 createPage({30 path: "media",31 component: pageTemplate,32 context: {},33 });34}35async function createGallery(createPage, graphql, reporter) {36 const pageTemplate = require.resolve(`./src/templates/gallery.js`);37 createPage({38 path: "gallery",39 component: pageTemplate,40 context: {},41 });42}43async function createHonors(createPage, graphql, reporter) {44 const pageTemplate = require.resolve(`./src/templates/honors.js`);45 createPage({46 path: "honors",47 component: pageTemplate,48 context: {},49 });50}51exports.createPages = async ({ actions, graphql, reporter }) => {52 const { createPage } = actions;53 await createLifeStory(createPage, graphql, reporter);54 await createBooks(createPage, graphql, reporter);55 await createEvents(createPage, graphql, reporter);56 await createMedia(createPage, graphql, reporter);57 await createGallery(createPage, graphql, reporter);58 await createHonors(createPage, graphql, reporter);59};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { createPage } from 'storybook-root-decorator';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { linkTo } from '@storybook/addon-links';5import { withInfo } from '@storybook/addon-info';6import { withKnobs, text, boolean, number } from '@storybook/addon-knobs/react';7import { withA11y } from '@storybook/addon-a11y';8import { withViewport } from '@storybook/addon-viewport';9import { withTests } from '@storybook/addon-jest';10import { withConsole } from '@storybook/addon-console';11import Button from '../src/components/Button';12import results from '../.jest-test-results.json';13const page = createPage({14});15storiesOf('Button', module)16 .addDecorator(page.withViewport())17 .addDecorator(page.withA11y())18 .addDecorator(page.withInfo())19 .addDecorator(page.withKnobs())20 .addDecorator(page.withConsole())21 .addDecorator(page.withTests())22 .add('with text', () => <Button onClick={action('clicked')}>Hello Button</Button>)23 .add('with some emoji', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>)24 .add('with some emoji and action', () => <Button onClick={action('clicked')}>😀 😎 👍 💯</Button>)25 .add('with some emoji and link', () => <Button onClick={linkTo('Button', 'with some emoji')}>😀 😎 👍 💯</Button>)26 .add('with some emoji and link', () => <Button onClick={link

Full Screen

Using AI Code Generation

copy

Full Screen

1import {createPage} from 'storybook-root';2import {Page} from 'playwright';3let page: Page;4beforeAll(async () => {5 page = await createPage();6});7afterAll(async () => {8 await page.close();9});10test('my test', async () => {11 await page.screenshot({path: 'example.png'});12});13module.exports = {14};15{16 "scripts": {17 }18}19module.exports = {20 core: {21 },22};23import {initialize} from 'storybook-root';24initialize();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { createPage } from 'storybook-root'2createPage({3})4import { createPage } from 'storybook-root'5createPage({6 meta: { description: 'This is my page' }7})8import { createPage } from 'storybook-root'9createPage({10 meta: {11 }12})13import { createPage } from 'storybook-root'14createPage({15 meta: {16 },17 custom: {18 }19})

Full Screen

Using AI Code Generation

copy

Full Screen

1import { createPage } from 'storybook-root';2createPage({3});4import { createPage } from 'storybook-root';5createPage({6});7import { createPage } from 'storybook-root';8createPage({9});10import { createPage } from 'storybook-root';11createPage({12});13import { createPage } from 'storybook-root';14createPage({15});16import { createPage } from 'storybook-root';17createPage({18});19import { createPage } from 'storybook-root';20createPage({

Full Screen

Using AI Code Generation

copy

Full Screen

1import { createPage } from 'storybook-root'2export default createPage({3 props: {4 name: {5 }6 },7 data: () => ({8 }),9 computed: {10 fullName() {11 }12 },13 methods: {14 changeName() {15 }16 },17 <h1>{{fullName}}</h1>18})19import { createStorybook } from 'storybook-root'20import Test from './test'21createStorybook({22 {23 }24})25{26 "scripts": {27 }28}29import { configure } from '@storybook/vue'30import { addDecorator } from '@storybook/vue'31import { withKnobs } from '@storybook/addon-knobs'32import { withNotes } from '@storybook/addon-notes'33import { withA11y } from '@storybook/addon-a11y'34addDecorator(withKnobs)35addDecorator(withNotes)36addDecorator(withA11y)37configure(require.context('../src', true, /\.stories\.js$/), module)38import { addParameters } from '@storybook/vue'39import { withKnobs } from '@storybook/addon-knobs'40import { withNotes } from '@storybook/addon-notes'41import { withA11y } from '@storybook/addon-a11y'42import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'43import { themes } from '@storybook/theming'44import { addDecorator } from '@

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful