// Instantiate a loader
const loader = new LDrawLoader();
// Optionally set library parts path
// loader.setPartsLibraryPath( path to library );
// Load a LDraw resource
loader.load(
// resource URL
'models/car.ldr_Packed.mpd',
// called when the resource is loaded
function ( group ) {
// Optionally, use LDrawUtils.mergeObject() from
// 'examples/jsm/utils/LDrawUtils.js' to merge all
// geometries by material (it gives better runtime
// performance, but construction steps are lost)
// group = LDrawUtils.mergeObject( group );
scene.add( group );
},
// called while loading is progressing
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
//...
test('should merge release branch into base branch', async (t) => {
t.plan(2);
await release.initialiseGitClient();
sandbox.stub(gitClientInstance, 'mergeBack');
await release.mergeBack();
t.equal(gitClientInstance.mergeBack.callCount, 1, 'Branch has been merged');
t.ok(gitClientInstance.mergeBack.calledWith(baseBranch, releaseBranch), 'Release branch has been merged into base branch');
sandbox.restore();
t.end();
});
//...
import {Component, NgModule} from '@angular/core'
import {render, screen} from '@testing-library/angular'
import {ngMocks} from 'ng-mocks'
@Component({
selector: 'app-parent-component',
template: '<app-child-component></app-child-component>',
})
class ParentComponent {}
@Component({
selector: 'app-child-component',
template: '<p>Child component</p>',
})
class ChildComponent {}
@NgModule({
declarations: [ParentComponent, ChildComponent],
})
export class AppModule {}
describe('ParentComponent', () => {
it('should not render ChildComponent when shallow rendering', async () => {
const dependencies = ngMocks.guts(null, AppModule, ParentComponent)
await render(ParentComponent, dependencies)
expect(screen.queryByText('Child component')).toBeNull()
})
})
const { ApolloServer, gql } = require('apollo-server');
const libraries = [
{
branch: 'downtown'
},
{
branch: 'riverside'
},
];
// The branch field of a book indicates which library has it in stock
const books = [
{
title: 'The Awakening',
author: 'Kate Chopin',
branch: 'riverside'
},
{
title: 'City of Glass',
author: 'Paul Auster',
branch: 'downtown'
},
];
// Schema definition
const typeDefs = gql`
# A library has a branch and books
type Library {
branch: String!
books: [Book!]
}
# A book has a title and author
type Book {
title: String!
author: Author!
}
# An author has a name
type Author {
name: String!
}
# Queries can fetch a list of libraries
type Query {
libraries: [Library]
}
`;
// Resolver map
const resolvers = {
Query: {
libraries() {
// Return our hardcoded array of libraries
return libraries;
}
},
Library: {
books(parent) {
// Filter the hardcoded array of books to only include
// books that are located at the correct branch
return books.filter(book => book.branch === parent.branch);
}
},
Book: {
// The parent resolver (Library.books) returns an object with the
// author's name in the "author" field. Return a JSON object containing
// the name, because this field expects an object.
author(parent) {
return {
name: parent.author
};
}
}
// Because Book.author returns an object with a "name" field,
// Apollo Server's default resolver for Author.name will work.
// We don't need to define one.
};
// Pass schema definition and resolvers to the
// ApolloServer constructor
const server = new ApolloServer({ typeDefs, resolvers });
// Launch the server
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
//...
angular.module('app', []);
angular.element(document).ready(() => angular.bootstrap(document, ['app']));
//...