it('should have proper CSS class for presence', () => { let personaCards: angular.IAugmentedJQuery[] = [ angular.element('<uif-persona-card uif-presence="available"></uif-persona-card>'), angular.element('<uif-persona-card uif-presence="away"></uif-persona-card>'), angular.element('<uif-persona-card uif-presence="blocked"></uif-persona-card>'), angular.element('<uif-persona-card uif-presence="busy"></uif-persona-card>'), angular.element('<uif-persona-card uif-presence="dnd"></uif-persona-card>'), angular.element('<uif-persona-card uif-presence="offline"></uif-persona-card>') ]; for (let i: number = 0; i < personaCards.length; i++) { _compile(personaCards[i])(scope); } scope.$digest(); let expectedClasses: string[] = [ 'ms-Persona--available', 'ms-Persona--away', 'ms-Persona--blocked', 'ms-Persona--busy', 'ms-Persona--dnd', 'ms-Persona--offline' ]; let personaCard: JQuery; for (let i: number = 0; i < personaCards.length; i++) { personaCard = jQuery(personaCards[i]); let personaDiv: JQuery = personaCard.find('div.ms-Persona'); expect(personaDiv.length === 1).toBeTruthy(); expect(personaDiv).toHaveClass(expectedClasses[i]); } });
beforeEach(angularMocks.inject(function ($rootScope, $compile) { var ctrl: any = { colorSchemes: [ {name: 'Oranges', value: 'interpolateOranges', invert: 'dark'}, {name: 'Reds', value: 'interpolateReds', invert: 'dark'}, ], events: new Emitter(), height: 200, panel: { heatmap: { }, cards: { cardPadding: null, cardRound: null }, color: { mode: 'spectrum', cardColor: '#b4ff00', colorScale: 'linear', exponent: 0.5, colorScheme: 'interpolateOranges', fillBackground: false }, xBucketSize: 1000, xBucketNumber: null, yBucketSize: 1, yBucketNumber: null, xAxis: { show: true }, yAxis: { show: true, format: 'short', decimals: null, logBase: 1, splitFactor: null, min: null, max: null, removeZeroValues: false }, tooltip: { show: true, seriesStat: false, showHistogram: false }, highlightCards: true }, renderingCompleted: sinon.spy(), hiddenSeries: {}, dashboard: { getTimezone: sinon.stub().returns('utc') }, range: { from: moment.utc("01 Mar 2017 10:00:00"), to: moment.utc("01 Mar 2017 11:00:00"), }, }; var scope = $rootScope.$new(); scope.ctrl = ctrl; ctx.series = []; ctx.series.push(new TimeSeries({ datapoints: [[1, 1422774000000], [2, 1422774060000]], alias: 'series1' })); ctx.series.push(new TimeSeries({ datapoints: [[2, 1422774000000], [3, 1422774060000]], alias: 'series2' })); ctx.data = { heatmapStats: { min: 1, max: 3, minLog: 1 }, xBucketSize: ctrl.panel.xBucketSize, yBucketSize: ctrl.panel.yBucketSize }; setupFunc(ctrl, ctx); let logBase = ctrl.panel.yAxis.logBase; let bucketsData = convertToHeatMap(ctx.series, ctx.data.yBucketSize, ctx.data.xBucketSize, logBase); ctx.data.buckets = bucketsData; // console.log("bucketsData", bucketsData); // console.log("series", ctrl.panel.yAxis.logBase, ctx.series.length); let elemHtml = ` <div class="heatmap-wrapper"> <div class="heatmap-canvas-wrapper"> <div class="heatmap-panel" style='width:${elementWidth}px'></div> </div> </div>`; var element = angular.element(elemHtml); $compile(element)(scope); scope.$digest(); ctrl.data = ctx.data; ctx.element = element; let render = rendering(scope, $(element), [], ctrl); ctrl.events.emit('render'); }));
import * as angular from "angular"; import { HelloComponent } from "./hello/hello.component"; angular.module("ng-ts-starterkit", []) .component(HelloComponent.selector, HelloComponent); angular.element(document).ready(function () { angular.bootstrap(document, ["ng-ts-starterkit"]); });
beforeEach(angularMocks.inject(function($rootScope, $compile) { var ctrl: any = { events: new Emitter(), height: 200, panel: { legend: {}, grid: { }, yaxes: [ { min: null, max: null, format: 'short', logBase: 1 }, { min: null, max: null, format: 'short', logBase: 1 } ], thresholds: [], xaxis: {}, seriesOverrides: [], tooltip: { shared: true } }, renderingCompleted: sinon.spy(), hiddenSeries: {}, dashboard: { getTimezone: sinon.stub().returns('browser') }, range: { from: moment([2015, 1, 1, 10]), to: moment([2015, 1, 1, 22]), }, }; var scope = $rootScope.$new(); scope.ctrl = ctrl; $rootScope.onAppEvent = sinon.spy(); ctx.data = []; ctx.data.push(new TimeSeries({ datapoints: [[1,1],[2,2]], alias: 'series1' })); ctx.data.push(new TimeSeries({ datapoints: [[1,1],[2,2]], alias: 'series2' })); setupFunc(ctrl, ctx.data); var element = angular.element("<div style='width:" + elementWidth + "px' grafana-graph><div>"); $compile(element)(scope); scope.$digest(); $.plot = ctx.plotSpy = sinon.spy(); ctrl.events.emit('render', ctx.data); ctx.plotData = ctx.plotSpy.getCall(0).args[1]; ctx.plotOptions = ctx.plotSpy.getCall(0).args[2]; }));
'validation.match', navbar, footer, main, constants, socket, util, lists, list ]) .config(routeConfig) .run(function($rootScope, $location, Auth) { 'ngInject'; // Redirect to login if route requires auth and you're not logged in $rootScope.$on('$stateChangeStart', function(event, next) { Auth.isLoggedIn(function(loggedIn) { if(next.authenticate && !loggedIn) { $location.path('/login'); } }); }); }); angular .element(document) .ready(() => { angular.bootstrap(document, ['myappApp'], { strictDi: true }); });
$scope.$on('$destroy', function() { angular.element(window).unbind('resize'); $scope.dashboard.destroy(); });
inject(($compile: Function, $rootScope: angular.IRootScopeService) => { element = angular.element('<uif-list><uif-list-item></uif-list-item></uif-list>'); $compile(element)(scope); scope.$digest(); expect(element.children().eq(0).children().eq(0).children().eq(0)).toHaveClass('ms-ListItem'); }));
beforeEach(inject(($rootScope: angular.IRootScopeService, $compile: Function, $q: angular.IQService) => { $element = angular.element(` <uif-people-picker uif-people="onSearch" ng-model="selectedPeople" placeholder="Search for people" uif-selected-person-click="personClicked"> <uif-people-search-more uif-disconnected="!connected"> <uif-secondary-text>Showing {{sourcePeople.length}} results</uif-secondary-text> <uif-primary-text uif-search-for-text="You are searching for: ">Search organization people</uif-primary-text> <uif-disconnected-text> We are having trouble connecting to the server. <br> Please try again in a few minutes.</uif-disconnected-text> </uif-people-search-more> </uif-people-picker>`); $scope = $rootScope; $scope.connected = false; let defaultGroup: any = { name: 'default', order: 1 }; $scope.people = [{ additionalData: [ { color: 'magenta', group: defaultGroup, icon: 'Persona.Person2.png', presence: 'available', primaryText: 'Joseph Pena', secondaryText: 'Contoso Inc.' } ], color: 'magenta', group: defaultGroup, icon: 'Persona.Person2.png', presence: 'available', primaryText: 'Russel Miller', secondaryText: 'Sales' }, { color: 'magenta', group: defaultGroup, icon: 'Persona.Person2.png', presence: 'available', primaryText: 'Russel Miller', secondaryText: 'Sales' }]; $scope.onSearch = (query) => { if (!query) { return $scope.people; } let deferred: angular.IDeferred<any> = $q.defer(); deferred.resolve([$scope.people[1]]); return deferred.promise; }; $compile($element)($scope); $element = jQuery($element[0]); $scope.$apply(); }));
it('should render the table header using a span tag', inject(($compile: Function, $rootScope: ng.IRootScopeService) => { element = ng.element('<uif-table><uif-table-row><uif-table-header></uif-table-header></uif-table-row></uif-table>'); $compile(element)(scope); scope.$digest(); expect(element.children().eq(0).children().eq(0).prop('tagName')).toEqual('SPAN'); }));
it('should set correct Office UI Fabric classes on the table cell', inject(($compile: Function, $rootScope: ng.IRootScopeService) => { element = ng.element('<uif-table-cell></uif-table-cell>'); $compile(element)(scope); scope.$digest(); expect(element).toHaveClass('ms-Table-cell'); }));