Skip to content

Commit

Permalink
Fix misspelling of Todo
Browse files Browse the repository at this point in the history
  • Loading branch information
zjuwjf committed Mar 15, 2019
1 parent 86701cd commit 96ae3b2
Show file tree
Hide file tree
Showing 23 changed files with 247 additions and 250 deletions.
2 changes: 1 addition & 1 deletion example/lib/todo_edit_page/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Widget buildView(
TodoEditState state, Dispatch dispatch, ViewService viewService) {
return Scaffold(
appBar: AppBar(
title: const Text('ToDo'),
title: const Text('Todo'),
),
body: Container(
padding: const EdgeInsets.all(16.0),
Expand Down
18 changes: 9 additions & 9 deletions test/adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,20 @@ void main() {
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onEdit', mockState.clone()),
Pin('onReduce', () {
ToDo toDo = mockState.list[0].clone();
Todo toDo = mockState.list[0].clone();
toDo.desc = '${toDo.desc}-effect';
mockState = toDoListReducer(
mockState, Action(ToDoListAction.edit, payload: toDo));
Expand Down Expand Up @@ -276,20 +276,20 @@ void main() {
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onEdit', mockState.clone()),
Pin('onReduce', () {
ToDo toDo = mockState.list[0].clone();
Todo toDo = mockState.list[0].clone();
toDo.desc = '${toDo.desc}-effect';
mockState = toDoListReducer(
mockState, Action(ToDoListAction.edit, payload: toDo));
Expand Down Expand Up @@ -352,20 +352,20 @@ void main() {
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onAdd', mockState.clone()),
Pin('onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('build', mockState.clone()),
Pin('onEdit', mockState.clone()),
Pin('onReduce', () {
ToDo toDo = mockState.list[0].clone();
Todo toDo = mockState.list[0].clone();
toDo.desc = '${toDo.desc}-effect';
mockState = toDoListReducer(
mockState, Action(ToDoListAction.edit, payload: toDo));
Expand Down
40 changes: 20 additions & 20 deletions test/component_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import 'package:test_widgets/test_base.dart';
import 'instrument.dart';
import 'track.dart';

class ToDoComponentInstrument extends TestComponent<ToDo> {
class ToDoComponentInstrument extends TestComponent<Todo> {
ToDoComponentInstrument(final Track track, int index,
{bool hasReducer = true})
: super(
view: instrumentView<ToDo>(toDoView,
(ToDo state, Dispatch dispatch, ViewService viewService) {
view: instrumentView<Todo>(toDoView,
(Todo state, Dispatch dispatch, ViewService viewService) {
track.append('toDo$index-build', state.clone());
}),
reducer: hasReducer
? instrumentReducer<ToDo>(toDoReducer,
change: (ToDo state, Action action) {
? instrumentReducer<Todo>(toDoReducer,
change: (Todo state, Action action) {
track.append('toDo$index-onReduce', state.clone());
})
: null,
effect: instrumentEffect<ToDo>(toDoEffect,
(Action action, Get<ToDo> getState) {
effect: instrumentEffect<Todo>(toDoEffect,
(Action action, Get<Todo> getState) {
if (action.type == ToDoAction.onEdit) {
track.append('toDo$index-onEdit', getState().clone());
} else if (action.type == ToDoAction.broadcast) {
Expand Down Expand Up @@ -55,18 +55,18 @@ class Component3 extends ToDoComponentInstrument {

Dependencies<ToDoList> toDoListDependencies(final Track track) =>
Dependencies<ToDoList>(slots: {
'toDo0': Component0(track).asDependent(Connector<ToDoList, ToDo>(
'toDo0': Component0(track).asDependent(Connector<ToDoList, Todo>(
get: (ToDoList toDoList) => toDoList.list[0],
set: (ToDoList toDoList, ToDo toDo) => toDoList.list[0] = toDo)),
'toDo1': Component1(track).asDependent(Connector<ToDoList, ToDo>(
set: (ToDoList toDoList, Todo toDo) => toDoList.list[0] = toDo)),
'toDo1': Component1(track).asDependent(Connector<ToDoList, Todo>(
get: (ToDoList toDoList) => toDoList.list[1],
set: (ToDoList toDoList, ToDo toDo) => toDoList.list[1] = toDo)),
'toDo2': Component2(track).asDependent(Connector<ToDoList, ToDo>(
set: (ToDoList toDoList, Todo toDo) => toDoList.list[1] = toDo)),
'toDo2': Component2(track).asDependent(Connector<ToDoList, Todo>(
get: (ToDoList toDoList) => toDoList.list[2],
set: (ToDoList toDoList, ToDo toDo) => toDoList.list[2] = toDo)),
'toDo3': Component3(track).asDependent(Connector<ToDoList, ToDo>(
set: (ToDoList toDoList, Todo toDo) => toDoList.list[2] = toDo)),
'toDo3': Component3(track).asDependent(Connector<ToDoList, Todo>(
get: (ToDoList toDoList) => toDoList.list[3],
set: (ToDoList toDoList, ToDo toDo) => toDoList.list[3] = toDo)),
set: (ToDoList toDoList, Todo toDo) => toDoList.list[3] = toDo)),
});

Widget pageView(
Expand All @@ -88,7 +88,7 @@ Widget pageView(
} else if (index == 3) {
return viewService.buildComponent('toDo3');
} else {
final ToDo toDo = state.list[index];
final Todo toDo = state.list[index];
return Container(
padding: const EdgeInsets.all(8.0),
margin: const EdgeInsets.all(8.0),
Expand Down Expand Up @@ -129,12 +129,12 @@ Widget pageView(
void main() {
group('component', () {
test('create', () {
final TestComponent<ToDo> component = TestComponent<ToDo>(
final TestComponent<Todo> component = TestComponent<Todo>(
view: toDoView, wrapper: (child) => ComponentWrapper(child));
expect(component, isNotNull);

final Widget componentWidget = component.buildComponent(
createPageStore<ToDo>(ToDo.mock(), null), () => ToDo.mock());
createPageStore<Todo>(Todo.mock(), null), () => Todo.mock());
expect(componentWidget, isNotNull);

expect(
Expand Down Expand Up @@ -343,13 +343,13 @@ void main() {
Pin('toDo1-build', mockState.list[1].clone()),
Pin('page-onAdd', mockState.clone()),
Pin('page-onReduce', () {
mockState.list.add(ToDo.mock());
mockState.list.add(Todo.mock());
return mockState.clone();
}),
Pin('page-build', mockState.clone()),
Pin('page-onAdd', mockState.clone()),
Pin('page-onReduce', () {
mockState.list.add(ToDo.mock());
mockState.list.add(Todo.mock());
return mockState.clone();
}),
Pin('page-build', mockState.clone()),
Expand Down
48 changes: 24 additions & 24 deletions test/dynamic_adapter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import 'package:test_widgets/test_base.dart';
import 'instrument.dart';
import 'track.dart';

class ToDoComponentInstrument extends TestComponent<ToDo> {
class ToDoComponentInstrument extends TestComponent<Todo> {
ToDoComponentInstrument(final Track track)
: super(
view: instrumentView<ToDo>(toDoView,
(ToDo state, Dispatch dispatch, ViewService viewService) {
view: instrumentView<Todo>(toDoView,
(Todo state, Dispatch dispatch, ViewService viewService) {
track.append('toDo-build', state.clone());
}),
reducer: instrumentReducer<ToDo>(toDoReducer,
change: (ToDo state, Action action) {
reducer: instrumentReducer<Todo>(toDoReducer,
change: (Todo state, Action action) {
track.append('toDo-onReduce', state.clone());
}),
effect: instrumentEffect<ToDo>(toDoEffect,
(Action action, Get<ToDo> getState) {
effect: instrumentEffect<Todo>(toDoEffect,
(Action action, Get<Todo> getState) {
if (action.type == ToDoAction.onEdit) {
track.append('toDo-onEdit', getState().clone());
} else if (action.type == ToDoAction.broadcast) {
Expand All @@ -33,19 +33,19 @@ class ToDoComponentInstrument extends TestComponent<ToDo> {
}
}),
shouldUpdate: shouldUpdate,
key: (ToDo toDo) => GlobalObjectKey(toDo.id),
key: (Todo toDo) => GlobalObjectKey(toDo.id),
);
}

class ToDoComponentNoReducer extends TestComponent<ToDo> {
class ToDoComponentNoReducer extends TestComponent<Todo> {
ToDoComponentNoReducer(final Track track)
: super(
view: instrumentView<ToDo>(toDoView,
(ToDo state, Dispatch dispatch, ViewService viewService) {
view: instrumentView<Todo>(toDoView,
(Todo state, Dispatch dispatch, ViewService viewService) {
track.append('toDo-build', state.clone());
}),
effect: instrumentEffect<ToDo>(toDoEffect,
(Action action, Get<ToDo> getState) {
effect: instrumentEffect<Todo>(toDoEffect,
(Action action, Get<Todo> getState) {
if (action.type == ToDoAction.onEdit) {
track.append('toDo-onEdit', getState().clone());
} else if (action.type == ToDoAction.broadcast) {
Expand All @@ -55,28 +55,28 @@ class ToDoComponentNoReducer extends TestComponent<ToDo> {
}
}),
shouldUpdate: shouldUpdate,
key: (ToDo toDo) => GlobalObjectKey(toDo.id),
key: (Todo toDo) => GlobalObjectKey(toDo.id),
);
}

Dependencies<ToDoList> toDoListDependencies(final Track track,
{bool noReducer = false}) =>
Dependencies<ToDoList>(
adapter: TestDynamicFlowAdapter<ToDoList>(
pool: <String, AbstractLogic<ToDo>>{
pool: <String, AbstractLogic<Todo>>{
'toDo': ToDoComponentInstrument(track),
'toDoNoReducer': ToDoComponentNoReducer(track),
},
connector: Connector<ToDoList, List<ItemBean>>(
get: (ToDoList toDoList) => toDoList.list
.map<ItemBean>((ToDo toDo) => noReducer
.map<ItemBean>((Todo toDo) => noReducer
? ItemBean('toDoNoReducer', toDo)
: ItemBean('toDo', toDo))
.toList(),
set: (ToDoList toDoList, List<ItemBean> beans) {
toDoList.list.clear();
toDoList.list.addAll(
beans.map<ToDo>((ItemBean bean) => bean.data).toList());
beans.map<Todo>((ItemBean bean) => bean.data).toList());
}),
reducer: instrumentReducer<ToDoList>(toDoListReducer,
change: (ToDoList state, Action action) {
Expand All @@ -97,7 +97,7 @@ void main() {
group('dynamic_flow_adapter', () {
test('create', () {
final Track track = Track();
final TestComponent<ToDo> component = ToDoComponentInstrument(track);
final TestComponent<Todo> component = ToDoComponentInstrument(track);
expect(component, isNotNull);

Widget page = TestPage<ToDoList, Map>(
Expand Down Expand Up @@ -320,7 +320,7 @@ void main() {
Pin('toDo-build', mockState.list[3].clone()),
Pin('toDo-onEdit', mockState.list[0].clone()),
Pin('toDo-onReduce', () {
final ToDo toDo = mockState.list[0].clone();
final Todo toDo = mockState.list[0].clone();
toDo.desc = '${toDo.desc}-effect';
mockState.list[0] =
toDoReducer(toDo, Action(ToDoAction.edit, payload: toDo));
Expand All @@ -330,7 +330,7 @@ void main() {
Pin('toDo-build', mockState.list[0].clone()),
Pin('toDo-onEdit', mockState.list[1].clone()),
Pin('toDo-onReduce', () {
final ToDo toDo = mockState.list[1].clone();
final Todo toDo = mockState.list[1].clone();
toDo.desc = '${toDo.desc}-effect';
mockState.list[1] =
toDoReducer(toDo, Action(ToDoAction.edit, payload: toDo));
Expand All @@ -341,11 +341,11 @@ void main() {
Pin('adapter-onAdd', mockState.clone()),
Pin('adapter-onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('page-build', mockState.clone()),
Pin('toDo-build', ToDo.mock()),
Pin('toDo-build', Todo.mock()),
]));
});

Expand Down Expand Up @@ -379,11 +379,11 @@ void main() {
Pin('adapter-onAdd', mockState.clone()),
Pin('adapter-onReduce', () {
mockState = toDoListReducer(
mockState, Action(ToDoListAction.add, payload: ToDo.mock()));
mockState, Action(ToDoListAction.add, payload: Todo.mock()));
return mockState.clone();
}),
Pin('page-build', mockState.clone()),
Pin('toDo-build', ToDo.mock()),
Pin('toDo-build', Todo.mock()),
]));
});

Expand Down
16 changes: 8 additions & 8 deletions test/lifecycle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import 'package:test_widgets/test_base.dart';
import 'instrument.dart';
import 'track.dart';

class ToDoComponentInstrument extends TestComponent<ToDo> {
class ToDoComponentInstrument extends TestComponent<Todo> {
ToDoComponentInstrument(final Track track)
: super(
view: toDoView,
reducer: toDoReducer,
effect: instrumentEffect<ToDo>(toDoEffect,
(Action action, Get<ToDo> getState) {
effect: instrumentEffect<Todo>(toDoEffect,
(Action action, Get<Todo> getState) {
if (action.type == ToDoAction.onEdit) {
track.append('toDo-onEdit');
print('toDo-onEdit');
Expand Down Expand Up @@ -46,10 +46,10 @@ class ToDoComponentInstrument extends TestComponent<ToDo> {
Dependencies<ToDoList> toDoListDependencies(final Track track) =>
Dependencies<ToDoList>(slots: {
'toDo': ToDoComponentInstrument(track).asDependent(
Connector<ToDoList, ToDo>(
Connector<ToDoList, Todo>(
get: (ToDoList toDoList) =>
toDoList.list.isNotEmpty ? toDoList.list[0] : ToDo.mock(),
set: (ToDoList toDoList, ToDo toDo) => toDoList.list.isNotEmpty
toDoList.list.isNotEmpty ? toDoList.list[0] : Todo.mock(),
set: (ToDoList toDoList, Todo toDo) => toDoList.list.isNotEmpty
? toDoList.list[0] = toDo
: toDoList))
});
Expand Down Expand Up @@ -95,12 +95,12 @@ Widget pageView(
void main() {
group('component', () {
test('create', () {
final TestComponent<ToDo> component = TestComponent<ToDo>(
final TestComponent<Todo> component = TestComponent<Todo>(
view: toDoView, wrapper: (child) => ComponentWrapper(child));
expect(component, isNotNull);

final Widget componentWidget = component.buildComponent(
createPageStore<ToDo>(ToDo.mock(), null), () => ToDo.mock());
createPageStore<Todo>(Todo.mock(), null), () => Todo.mock());
expect(componentWidget, isNotNull);

expect(
Expand Down
Loading

0 comments on commit 96ae3b2

Please sign in to comment.