Skip to content

Instantly share code, notes, and snippets.

it('example actions', function () {
// given:
var html = app.runHtml('<greeting name="defaultName"/>', {defaultName: 'John'});
// when:
html.perform(
type('Jane').in('input.name'),
click.in('button#hello')
);
it('sets the strength to "strong" if the password length is >8 chars', function() {
var $scope = {};
var controller = $controller('PasswordController', { $scope: $scope });
$scope.password = 'longerthaneightchars';
$scope.grade();
expect($scope.strength).toEqual('strong');
});
it('group of components test', function () {
const html = app.runHtml(`<div>
<my-first-component></my-first-component>
<my-second-component></my-second-component>
</div>`);
});
it('should fetch authentication token', function() {
let GET_received = false;
server.get('auth.py', req => {
GET_received = true;
req.sendStatus(200);
});
const html = app.runHtml('<my-component></my-component>');
expect(GET_received).toBeTruthy();
it('should fetch authentication token', function() {
$httpBackend.expectGET('/auth.py');
var controller = createController();
$httpBackend.flush();
});
it('value in input text should should be set', (done) => {
const stubFunc = jasmine.createSpy('spy');
const html = app.runHtml('<search-team-input on-search-change="searchCompetitions($text)"></search-team-input>',
{searchCompetitions: stubFunc});
html.perform(
type('2017').in('.year')
);
angular.module(module)
.run((_$rootScope_, _$state_, _SearchService_) => {
$scope = _$rootScope_.$new();
$state = _$state_;
searchService = _SearchService_;
});
it('serviceshould be extecuted once', () => {
const html = app.runHtml('<home-component></home-component>');
searchService.showMe();
expect(searchService.showMe.calls.count()).toBe(1); // Error
});
it('serviceshould be extecuted once', () => {
angular.module(HomeModule.name)
.run((_homeService_) => {
homeService = _homeService_;
});
angular
.module('app', [])
.component('counter', {
template: '<div class="counter"></div>',
controllerAs: 'ctrl',
controller: function () {
const self = this;
}
});