summaryrefslogtreecommitdiffstats
path: root/catalog-ui/app/third-party/ng-infinite-scroll/test
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui/app/third-party/ng-infinite-scroll/test
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/app/third-party/ng-infinite-scroll/test')
-rw-r--r--catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js27
-rw-r--r--catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js26
-rw-r--r--catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js32
-rw-r--r--catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee221
4 files changed, 0 insertions, 306 deletions
diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js
deleted file mode 100644
index 134c723f91..0000000000
--- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-local.conf.js
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-var config = require('./protractor-shared.conf').config;
-
-config.multiCapabilities = [
- { browserName: 'chrome' }
-];
-
-exports.config = config;
diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js
deleted file mode 100644
index d1e567d7b4..0000000000
--- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-shared.conf.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-exports.config = {
- specs: ['**/*.spec.coffee'],
- baseUrl: 'http://localhost:8000/',
- allScriptsTimeout: 30000,
- getPageTimeout: 30000
-};
diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js b/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js
deleted file mode 100644
index 54fe0bd828..0000000000
--- a/catalog-ui/app/third-party/ng-infinite-scroll/test/protractor-travis.conf.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed 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.
- * ============LICENSE_END=========================================================
- */
-
-var config = require('./protractor-shared.conf').config;
-
-// All available platform / browser combinations can be found on https://saucelabs.com/platforms
-config.multiCapabilities = [
- {
- browserName: 'chrome',
- platform: 'OS X 10.10',
- version: '37'
- }
-];
-
-exports.config = config;
diff --git a/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee b/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee
deleted file mode 100644
index 07e6fec8be..0000000000
--- a/catalog-ui/app/third-party/ng-infinite-scroll/test/spec/ng-infinite-scroll.spec.coffee
+++ /dev/null
@@ -1,221 +0,0 @@
-fs = require "fs"
-mkdirp = require "mkdirp"
-
-getTemplate = (angularVersion, container, attrs, throttle) ->
- """
- <!doctype html>
- <head>
- <style>
- html, body {
- height: 100%;
- }
- </style>
- <script src='http://ajax.googleapis.com/ajax/libs/angularjs/#{angularVersion}/angular.min.js'></script>
- <script src="../../build/ng-infinite-scroll.js"></script>
- <script>
- angular.module('app', ['infinite-scroll'])
- .config(function ($provide) {
- $provide.value('THROTTLE_MILLISECONDS', #{throttle});
- })
- .run(function ($rootScope) {
- $rootScope.items = [];
- $rootScope.loadMore = function () {
- [].push.apply($rootScope.items, new Array(100));
- };
-
- $rootScope.busy = true;
-
- $rootScope.enable = function () {
- $rootScope.busy = false;
- };
-
- $rootScope.triggerEvent = function () {
- $rootScope.$emit('anEvent');
- };
- });
- </script>
- </head>
- <body ng-app="app">
- <a id="action" ng-click="enable()">Enable</a>
- <a id="force" ng-click="loadMore()">Force</a>
- <a id="trigger" ng-click="triggerEvent()">Trigger</a>
- #{containers[container].start}
- <div infinite-scroll="loadMore()" #{containers[container].attr} #{attrs}>
- <p ng-repeat='item in items track by $index'>
- {{$index}}
- </p>
- </div>
- #{containers[container].end}
- </body>
- """
-
-containers =
- window:
- start: ""
- end: ""
- attr: ""
- parent:
- start: "<div id='parent' style='height: 50%; overflow: auto;'>"
- end: "</div>"
- attr: "infinite-scroll-parent"
- ancestor:
- start: "<div id='ancestor' style='height: 50%; overflow: auto;'><div>"
- end: "</div></div>"
- attr: "infinite-scroll-container='\"#ancestor\"'"
-
-getElementByIdScript = (id) ->
- "document.getElementById('#{id}')"
-
-calculateChildrenHeightScript = (id) ->
- """
- [].concat.apply([], #{getElementByIdScript(id)}.childNodes)
- .map(function (el) { return el.offsetHeight ? el.offsetHeight : 0; })
- .reduce(function (cur, prev) { return prev + cur; }, 0)
- """
-
-scrollToBottomScript = (container) ->
- if container is "window"
- "window.scrollTo(0, document.body.scrollHeight)"
- else
- "#{getElementByIdScript(container)}.scrollTop = #{calculateChildrenHeightScript(container)}"
-
-scrollToLastScreenScript = (container, offset) ->
- # 2 * window.innerHeight means that the bottom of the screen should be somewhere close to
- # body height - window height. That means that the top of the window is body height - 2 * window height.
- if container is "window"
- "window.scrollTo(0, document.body.scrollHeight - 2 * window.innerHeight + #{offset})"
- else
- """
- #{getElementByIdScript(container)}.scrollTop =
- #{calculateChildrenHeightScript(container)} - 2 * #{getElementByIdScript(container)}.offsetHeight + #{offset}
- """
-
-collapseItemsScript = (container) ->
- """
- var items = document.getElementsByTagName('p')
- for (i = 0; i < items.length; ++i) {
- items[i].style.display = 'none'
- }
- """
-
-getItems = ->
- element.all(By.repeater "item in items")
-
-tmpDir = ".tmp"
-pathToDocument = "#{tmpDir}/index.html"
-
-describe "ng-infinite-scroll", ->
- for angularVersion in ["1.2.0", "1.3.4"]
- describe "with Angular #{angularVersion}", ->
- for container in ["window", "ancestor", "parent"]
- describe "with #{container} as container", ->
-
- replaceIndexFile = (attrs, throttle) ->
- mkdirp tmpDir
- fs.writeFileSync(pathToDocument, getTemplate(angularVersion, container, attrs, throttle))
-
- describe "without throttling", ->
-
- throttle = null
-
- it "should be triggered immediately and when container is scrolled to the bottom", ->
- replaceIndexFile "", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToBottomScript(container))
- expect(getItems().count()).toBe 200
-
- it "does not trigger immediately when infinite-scroll-immediate-check is false", ->
- replaceIndexFile "infinite-scroll-immediate-check='false'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 0
- element(By.id("force")).click()
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToBottomScript(container))
- expect(getItems().count()).toBe 200
-
- it "respects the disabled attribute", ->
- replaceIndexFile "infinite-scroll-disabled='busy'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 0
- element(By.id("action")).click()
- expect(getItems().count()).toBe 100
-
- it "respects the infinite-scroll-distance attribute", ->
- replaceIndexFile "infinite-scroll-distance='1'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToLastScreenScript(container, -20))
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToLastScreenScript(container, 20))
- expect(getItems().count()).toBe 200
-
- describe "with an event handler", ->
-
- it "calls the event handler on an event", ->
- replaceIndexFile "infinite-scroll-listen-for-event='anEvent'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(collapseItemsScript(container))
- expect(getItems().count()).toBe 100
- element(By.id("trigger")).click()
- expect(getItems().count()).toBe 200
-
- describe "with throttling", ->
-
- throttle = browser.params.testThrottleValue
-
- it "should be triggered immediately and when container is scrolled to the bottom", ->
- replaceIndexFile "", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToBottomScript(container))
- expect(getItems().count()).toBe 100
- browser.sleep(throttle)
- expect(getItems().count()).toBe 200
-
- it "does not trigger immediately when infinite-scroll-immediate-check is false", ->
- replaceIndexFile "infinite-scroll-immediate-check='false'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 0
- element(By.id("force")).click()
- expect(getItems().count()).toBe 100
-
- it "respects the disabled attribute and is throttled when page loads", ->
- replaceIndexFile "infinite-scroll-disabled='busy'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 0
- element(By.id("action")).click()
- expect(getItems().count()).toBe 0
- browser.sleep(throttle)
- expect(getItems().count()).toBe 100
-
- it "is not throttled when re-enabled if the throttle time has already elapsed", ->
- replaceIndexFile "infinite-scroll-disabled='busy'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 0
- browser.sleep(throttle)
- element(By.id("action")).click()
- expect(getItems().count()).toBe 100
-
- it "respects the infinite-scroll-distance attribute", ->
- replaceIndexFile "infinite-scroll-distance='1'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(scrollToLastScreenScript(container, 20))
- expect(getItems().count()).toBe 100
- browser.sleep(throttle)
- expect(getItems().count()).toBe 200
-
- describe "with an event handler", ->
-
- it "calls the event handler on an event", ->
- replaceIndexFile "infinite-scroll-listen-for-event='anEvent'", throttle
- browser.get pathToDocument
- expect(getItems().count()).toBe 100
- browser.driver.executeScript(collapseItemsScript(container))
- expect(getItems().count()).toBe 100
- element(By.id("trigger")).click()
- expect(getItems().count()).toBe 100
- browser.sleep(throttle)
- expect(getItems().count()).toBe 200