Unverified Commit c4beb731 authored by Sean Hammond's avatar Sean Hammond Committed by GitHub

Merge pull request #668 from hypothesis/ng-16-update

Update to Angular 1.6.9
parents 8b779858 e68aa1ab
......@@ -7,10 +7,10 @@
"bugs": "https://github.com/hypothesis/client/issues",
"repository": "hypothesis/client",
"devDependencies": {
"angular": "~1.5.6",
"angular-mocks": "~1.5.6",
"angular-route": "~1.5.6",
"angular-sanitize": "~1.5.6",
"angular": "^1.6.9",
"angular-mocks": "^1.6.9",
"angular-route": "^1.6.9",
"angular-sanitize": "^1.6.9",
"angular-toastr": "^1.7.0",
"angulartics": "0.17.2",
"autofill-event": "0.0.1",
......
......@@ -146,7 +146,8 @@ describe('annotation', function() {
})
.component('markdown', {
bindings: require('../markdown').bindings,
});
})
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(angular.mock.module('h'));
......@@ -709,8 +710,13 @@ describe('annotation', function() {
it('flashes an error if the delete fails on the server', function(done) {
var controller = createDirective().controller;
sandbox.stub($window, 'confirm').returns(true);
var err = new Error('500 Server Error');
fakeAnnotationMapper.deleteAnnotation.returns($q.reject(err));
fakeAnnotationMapper.deleteAnnotation = sinon.spy(() => {
// nb. we only instantiate the rejected promise when
// `deleteAnnotation` is called to avoid triggering `$q`'s unhandled
// promise rejection handler during the `$timeout.flush()` call.
return $q.reject(new Error('500 Server Error'));
});
controller.delete().then(function() {
assert.calledWith(fakeFlash.error,
'500 Server Error', 'Deleting annotation failed');
......
......@@ -35,7 +35,8 @@ describe('annotationViewerContent', function () {
before(function () {
angular.module('h', [])
.component('annotationViewerContent',
require('../annotation-viewer-content'));
require('../annotation-viewer-content'))
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(angular.mock.module('h'));
......
......@@ -57,7 +57,8 @@ describe('sidebar.components.hypothesis-app', function () {
}));
angular.module('h', [])
.component('hypothesisApp', component);
.component('hypothesisApp', component)
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(angular.mock.module('h'));
......
......@@ -51,22 +51,19 @@ describe('publishAnnotationBtn', function () {
});
it('should display "Post to Research Lab"', function () {
element.link({
group: {
name: 'Research Lab',
type: 'group',
},
isShared: true,
});
element.ctrl.group = {
name: 'Research Lab',
type: 'group',
};
element.ctrl.isShared = true;
element.scope.$digest();
var buttons = element.find('button');
assert.equal(buttons[0].innerHTML, 'Post to Research Lab');
});
it('should save when "Post..." is clicked', function () {
var savedSpy = sinon.spy();
element.link({
onSave: savedSpy,
});
element.ctrl.onSave = savedSpy;
assert.ok(!savedSpy.called);
angular.element(element.find('button')[0]).click();
assert.ok(savedSpy.calledOnce);
......@@ -74,11 +71,9 @@ describe('publishAnnotationBtn', function () {
it('should change privacy when privacy option selected', function () {
var privacyChangedSpy = sinon.spy();
element.link({
// for existing annotations, the privacy should not be changed
// unless the user makes a choice from the list
onSetPrivacy: privacyChangedSpy,
});
// for existing annotations, the privacy should not be changed
// unless the user makes a choice from the list
element.ctrl.onSetPrivacy = privacyChangedSpy;
assert.ok(!privacyChangedSpy.called);
var privateOption = element.find('li')[1];
......@@ -90,25 +85,22 @@ describe('publishAnnotationBtn', function () {
});
it('should disable post buttons when posting is not possible', function () {
element.link({
canPost: false,
});
element.ctrl.canPost = false;
element.scope.$digest();
var disabledBtns = element.find('button[disabled]');
assert.equal(disabledBtns.length, 1);
// check that buttons are enabled when posting is possible
element.link({
canPost: true,
});
element.ctrl.canPost = true;
element.scope.$digest();
disabledBtns = element.find('button[disabled]');
assert.equal(disabledBtns.length, 0);
});
it('should revert changes when cancel is clicked', function () {
var cancelSpy = sinon.spy();
element.link({
onCancel: cancelSpy,
});
element.ctrl.onCancel = cancelSpy;
element.scope.$digest();
var cancelBtn = element.find('.publish-annotation-cancel-btn');
assert.equal(cancelBtn.length, 1);
angular.element(cancelBtn).click();
......
......@@ -62,7 +62,8 @@ describe('sidebar.components.sidebar-content', function () {
angular: angular,
'../search-client': FakeSearchClient,
})
));
))
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(angular.mock.module('h'));
......
......@@ -26,7 +26,8 @@ describe('StreamContentController', function () {
before(function () {
angular.module('h', [])
.component('streamContent', require('../stream-content'));
.component('streamContent', require('../stream-content'))
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(function () {
......
......@@ -7,7 +7,8 @@ var util = require('../../directive/test/util');
describe('svgIcon', function () {
before(function () {
angular.module('app', [])
.component('svgIcon', require('../svg-icon'));
.component('svgIcon', require('../svg-icon'))
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(function () {
......
......@@ -114,7 +114,8 @@ describe('threadList', function () {
before(function () {
angular.module('app', [])
.component('threadList', threadList);
.component('threadList', threadList)
.config(($compileProvider) => $compileProvider.preAssignBindingsEnabled(true));
});
beforeEach(function () {
......
......@@ -147,7 +147,6 @@ function createDirective(document, name, attrs, initialScope, initialHtml, opts)
var childScope = $scope.$new();
angular.extend(childScope, props);
var element = linkFn(childScope);
element.link = linkDirective;
element.scope = childScope;
childScope.$digest();
element.ctrl = element.controller(name);
......
......@@ -97,6 +97,19 @@ function configureToastr(toastrConfig) {
});
}
// @ngInject
function configureCompile($compileProvider) {
// Make component bindings available in controller constructor. When
// pre-assigned bindings is off, as it is by default in Angular >= 1.6.0,
// bindings are only available during and after the controller's `$onInit`
// method.
//
// This migration helper is being removed in Angular 1.7.0. To see which
// components need updating, look for uses of `preAssignBindingsEnabled` in
// tests.
$compileProvider.preAssignBindingsEnabled(true);
}
// @ngInject
function setupHttp($http, streamer) {
$http.defaults.headers.common['X-Client-Id'] = streamer.clientId;
......@@ -205,6 +218,7 @@ module.exports = angular.module('h', [
.value('time', require('./time'))
.value('urlEncodeFilter', require('./filter/url').encode)
.config(configureCompile)
.config(configureLocation)
.config(configureRoutes)
.config(configureToastr)
......
......@@ -98,25 +98,25 @@ ancestors@0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/ancestors/-/ancestors-0.0.3.tgz#124eb944447d68b302057047d15d077a9da5179d"
angular-mocks@~1.5.6:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.5.11.tgz#a0e1dd0ea55fd77ee7a757d75536c5e964c86f81"
angular-mocks@^1.6.9:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular-mocks/-/angular-mocks-1.6.9.tgz#4fed8c8293a5080e0919a7ff0dcf0f704864b7ba"
angular-route@~1.5.6:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular-route/-/angular-route-1.5.11.tgz#49614f3a167f54291e449fe8ba05d39c58924b83"
angular-route@^1.6.9:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular-route/-/angular-route-1.6.9.tgz#73c63cec6a8a6b924698aec635eac32aa41f5e2b"
angular-sanitize@~1.5.6:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular-sanitize/-/angular-sanitize-1.5.11.tgz#ebfb3f343e543f9b2ef050fb4c2e9ee048d1772f"
angular-sanitize@^1.6.9:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular-sanitize/-/angular-sanitize-1.6.9.tgz#1adba33f6f513e5f93e3aca8071bef53666739ea"
angular-toastr@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/angular-toastr/-/angular-toastr-1.7.0.tgz#7fdf9ef61cb4abee7a8818eb3d9798c057d4eb7f"
angular@~1.5.6:
version "1.5.11"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.5.11.tgz#8c5ba7386f15965c9acf3429f6881553aada30d6"
angular@^1.6.9:
version "1.6.9"
resolved "https://registry.yarnpkg.com/angular/-/angular-1.6.9.tgz#bc812932e18909038412d594a5990f4bb66c0619"
angulartics@0.17.2:
version "0.17.2"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment