henningn commented on a change in pull request #94: URL: https://github.com/apache/myfaces-tobago/pull/94#discussion_r427891891
########## File path: tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/60-split/Split_Layout.test.js ########## @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js"; +import {querySelectorFn} from "/script/tobago-test.js"; + +it("SplitLayout Example 1", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example1") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example1"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example1"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example1"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 2", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example2") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example2"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example2"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example2"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3a", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3a") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3a"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3a"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3a"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3b", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3b") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3b"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3b"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3b"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === 0).toBe(true)); + test.do(() => expect(verticalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +function getHorizontalSplitters(element) { + return querySelectorFn(element)().querySelectorAll(":scope > .tobago-splitLayout-horizontal, :scope > .tobago-splitLayout-horizontal").length; Review comment: why is the expression duplicated? ########## File path: tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/60-split/Split_Layout.test.js ########## @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js"; +import {querySelectorFn} from "/script/tobago-test.js"; + +it("SplitLayout Example 1", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example1") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example1"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example1"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example1"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 2", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example2") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example2"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example2"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example2"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3a", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3a") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3a"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3a"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3a"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3b", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3b") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3b"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3b"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3b"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === 0).toBe(true)); + test.do(() => expect(verticalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +function getHorizontalSplitters(element) { + return querySelectorFn(element)().querySelectorAll(":scope > .tobago-splitLayout-horizontal, :scope > .tobago-splitLayout-horizontal").length; +} + +function getVerticalSplitters(element) { + return querySelectorFn(element)().querySelectorAll(":scope > .tobago-splitLayout-vertical, :scope > .tobago-splitLayout-vertical").length; Review comment: why is the expression duplicated? ########## File path: tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/60-split/Split_Layout.xhtml ########## @@ -47,7 +47,7 @@ <tc:style minWidth="150px"/> </tc:textarea> </tc:splitLayout></code></pre> - <tc:splitLayout columns="2fr 1fr 1fr"> + <tc:splitLayout id="Example1" columns="2fr 1fr 1fr"> Review comment: IDs should start with a lower case character. ########## File path: tobago-example/tobago-example-demo/src/main/webapp/content/30-concept/16-layout/60-split/Split_Layout.test.js ########## @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {JasmineTestTool} from "/tobago/test/tobago-test-tool.js"; +import {querySelectorFn} from "/script/tobago-test.js"; + +it("SplitLayout Example 1", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example1") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example1"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example1"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example1"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 2", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example2") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example2"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example2"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example2"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3a", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3a") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3a"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3a"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3a"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(verticalSplitters === 0).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +it("SplitLayout Example 3b", function (done) { + let expectedSplitters = getElements("#page\\:mainForm\\:Example3b") - 1; + let horizontalSplitters = getHorizontalSplitters("#page\\:mainForm\\:Example3b"); + let verticalSplitters = getVerticalSplitters("#page\\:mainForm\\:Example3b"); + let doubleSplitters = hasDoubleSplitter("#page\\:mainForm\\:Example3b"); + + const test = new JasmineTestTool(done); + test.do(() => expect(horizontalSplitters === 0).toBe(true)); + test.do(() => expect(verticalSplitters === expectedSplitters).toBe(true)); + test.do(() => expect(doubleSplitters === false).toBe(true)); + test.start(); +}); + +function getHorizontalSplitters(element) { + return querySelectorFn(element)().querySelectorAll(":scope > .tobago-splitLayout-horizontal, :scope > .tobago-splitLayout-horizontal").length; +} + +function getVerticalSplitters(element) { + return querySelectorFn(element)().querySelectorAll(":scope > .tobago-splitLayout-vertical, :scope > .tobago-splitLayout-vertical").length; +} + +function hasDoubleSplitter(element) { + let counter = 0; + let elements = querySelectorFn(element)().children; + + for (let item of elements) { + if(item.className === "tobago-splitLayout-horizontal" || item.className === "tobago-splitLayout-vertical") { Review comment: Use item.classList to check if a CSS class is set. className return the whole string of the 'class' attribute. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
