// Copyright 2017 Google Inc. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file or at // https://developers.google.com/open-source/licenses/bsd import 'package:ngflutter/src/page_object_data.dart'; import 'package:test/test.dart'; void main() { group('PageObjectData', () { test('should generate items.', () { var po = new PageObjectData( '', ); expect(po.variables.first.getterString, 'Future get good => _getGood();'); expect(po.variables.first.internalString, "@ByClass('good')\n Lazy _getGood;"); expect(po.variables.first.type.uri, 'package:pageloader/objects.dart'); }); test('should generate items in list', () { var po = new PageObjectData( '', ); expect(po.variables.first.getterString, 'Future> get good => _getGood();'); expect(po.variables.first.internalString, "@ByClass('good')\n Lazy> _getGood;"); }); test('should generate items in parents list', () { var po = new PageObjectData( '

' '

', ); expect(po.variables.first.getterString, 'Future> get good => _getGood();'); expect(po.variables.first.internalString, "@ByClass('good')\n Lazy> _getGood;"); }); test('should generate items with default type', () { var po = new PageObjectData(''); expect(po.variables.first.getterString, 'Future get cool => _getCool();'); expect(po.variables.first.internalString, "@ByClass('cool')\n Lazy _getCool;"); expect(po.variables.first.type.uri, 'package:pageloader/objects.dart'); }); test('should sort generated items', () { var po1 = new PageObjectData( '' '', ); expect(po1.variables.first.name, 'Bad'); expect(po1.variables.last.name, 'Good'); var po2 = new PageObjectData( '' '', ); expect(po2.variables.first.name, 'Bad'); expect(po2.variables.last.name, 'Good'); }); test('should ignore some tags.', () { var po = new PageObjectData('

123

'); expect(po.variables.isEmpty, true); }); test('should add optional annotation.', () { var po = new PageObjectData(''); expect(po.variables[0].internalString, startsWith('@optional')); }); test('should add optional annotation when parent is optional.', () { var po = new PageObjectData( '
'); expect(po.variables[0].internalString, startsWith('@optional')); }); test('should add optional annotation when in